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

Release 3.5.0 #68

Merged
merged 61 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ba1e3af
Now sdk has no dependencies on cli. But structure remains the same.
Arondondon Jul 25, 2024
b6be103
Tiny fixes
Arondondon Jul 25, 2024
bf22dc5
Modified README.md
Arondondon Aug 13, 2024
da5c483
Modified README.md x2
Arondondon Aug 13, 2024
e0b5006
Tiny fixes in README.md.
Arondondon Aug 13, 2024
489be2d
Finished init.md doc
Arondondon Aug 14, 2024
5410722
Minor format fixes
Arondondon Aug 14, 2024
c495bef
Minor format fixes (x2)
Arondondon Aug 14, 2024
8d37597
service_client.md is made up to and including "get_price", minor form…
Arondondon Aug 14, 2024
94721a5
Finished service_client.md
Arondondon Aug 15, 2024
bd5f56b
Tiny fixes
Arondondon Aug 15, 2024
3649be1
Finished account.md
Arondondon Aug 15, 2024
ebac407
Minor fixes
Arondondon Aug 15, 2024
502d4a2
Finished concurrency_manager.md
Arondondon Aug 15, 2024
e3f946a
Some fixes in concurrency_manager.md
Arondondon Aug 16, 2024
9ba9c79
Finished ipfs_metadata_provider.md and metadata_provider.md
Arondondon Aug 16, 2024
cefebc0
Finished mpe_contract.md
Arondondon Aug 16, 2024
b7c5bf2
Tiny fixes...again
Arondondon Aug 16, 2024
02dfdc1
Finished payment_channel.md
Arondondon Aug 16, 2024
e6e6c9e
One fix
Arondondon Aug 16, 2024
fc43e69
Finished payment_channel_provider.md
Arondondon Aug 16, 2024
6abbbc0
Finished payment_strategy.md
Arondondon Aug 19, 2024
46f799d
Some additions and corrections
Arondondon Aug 19, 2024
091de6e
Finished default_payment_strategy.md
Arondondon Aug 19, 2024
38fa04f
Tiny fixes
Arondondon Aug 19, 2024
c2de185
Finished freecall_payment_strategy.md
Arondondon Aug 19, 2024
030e003
Tiny change
Arondondon Aug 22, 2024
3ac2e02
Finished paidcall_payment_strategy.md
Arondondon Aug 22, 2024
1bf106e
Finished prepaid_payment_strategy.md
Arondondon Aug 22, 2024
7b6afdc
Minor fixes
Arondondon Aug 22, 2024
ca19006
Initial markup for training.md
Arondondon Aug 22, 2024
89acb8a
The structure of the README.md has been reworked and some new informa…
Arondondon Aug 26, 2024
030bcc8
Several changes in README.md
Arondondon Aug 27, 2024
7b2d5ca
Added two examples. calculator.py is finished, console_app.py is almo…
Arondondon Aug 27, 2024
1e0b5cc
Tiny fixes
Arondondon Aug 27, 2024
7a7df14
Reworked commands. Added several command implementations.
Arondondon Aug 29, 2024
a9a8e31
Finished console_app.py. Implemented updating channels.
Arondondon Aug 29, 2024
32f76dd
Added description (comments) to console_app.py. Added "balance" funct…
Arondondon Aug 29, 2024
e6da5d9
Added calculator.py file with the guide and description.
Arondondon Sep 5, 2024
c1ed006
Tiny fix.
Arondondon Sep 5, 2024
131c6e8
Added console_app.md as a description to console_app.py
Arondondon Sep 6, 2024
e3ecb86
Some fixes.
Arondondon Sep 6, 2024
35bd4c2
Tiny fix.
Arondondon Sep 6, 2024
05db37c
Global changes after getting rid of CLI dependencies. Unneeded module…
Arondondon Sep 10, 2024
79d40f6
Merge branch 'development' into docs-and-update-readme
Arondondon Sep 10, 2024
9000626
Merge pull request #1 from Arondondon/docs-and-update-readme
Arondondon Sep 10, 2024
11c2b37
Merge pull request #2 from Arondondon/depelopment-app-example
Arondondon Sep 10, 2024
5ba5ca3
The documentation structure of the SDK version without CLI dependenci…
Arondondon Sep 10, 2024
4125936
Finished client_lib_generator.md and ipfs_utils.md. Some fixes in sev…
Arondondon Sep 11, 2024
a777305
Finished service_metadata.md and config.md is half done. Some fixes i…
Arondondon Sep 12, 2024
fada44a
Finished config.md.
Arondondon Sep 13, 2024
f855997
Added and finished training.md
Arondondon Sep 13, 2024
5692244
Tiny fix.
Arondondon Sep 13, 2024
e6a2a9c
Fixed all bugs related to links in .md files. Fixed wrong module name…
Arondondon Sep 13, 2024
2bb8a71
Got rid of local storage of client configuration. Now config is store…
mirel-dev Sep 20, 2024
11cff0c
Merge pull request #3 from Arondondon/getting_rid_of_config_file
Arondondon Sep 20, 2024
4418f91
Changes in documentation, examples and README files related to the co…
Arondondon Sep 20, 2024
ea97b5f
Fixed issues: grammatical in service_metadata.md and logical in calcu…
Arondondon Sep 26, 2024
de2a6ed
Merge pull request #62 from Arondondon/development
kiruxaspb Sep 26, 2024
2312606
upgrade version to 3.5.0
kiruxaspb Sep 26, 2024
a9ab0d0
Merge pull request #67 from singnet/update-version
kiruxaspb Sep 26, 2024
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
267 changes: 210 additions & 57 deletions README.md

Large diffs are not rendered by default.

208 changes: 208 additions & 0 deletions docs/main/account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
## module: sdk.account

[Link](https://github.com/singnet/snet-sdk-python/blob/master/snet/sdk/account.py) to GitHub

Entities:
1. [TransactionError](#class-transactionerror)
- [\_\_init\_\_](#__init__)
- [\_\_str\_\_](#__str__)
2. [Account](#class-account)
- [\_\_init\_\_](#__init__-1)
- [_get_nonce](#_get_nonce)
- [_get_gas_price](#_get_gas_price)
- [_send_signed_transaction](#_send_signed_transaction)
- [send_transaction](#send_transaction)
- [_parse_receipt](#_parse_receipt)
- [escrow_balance](#escrow_balance)
- [deposit_to_escrow_account](#deposit_to_escrow_account)
- [approve_transfer](#approve_transfer)
- [allowance](#allowance)

### Class `TransactionError`

extends: `Exception`

is extended by: -

#### description

`TransactionError` is a custom exception class that is raised when an Ethereum transaction receipt has a status of 0.
This indicates that the transaction failed. Can provide a custom message. Optionally includes receipt

#### attributes

- `message` (str): The exception message.
- `receipt` (dict): The transaction receipt.

#### methods

#### `__init__`

Initializes the exception with the provided message and receipt.

###### args:

- `message` (str): The exception message.
- `receipt` (dict): The transaction receipt. Defaults to _None_.

###### returns:

- _None_

#### `__str__`

Returns a string representation of the `TransactionError` object.

###### returns:

- A string containing the `message` attribute of the TransactionError object. (str)

### Class `Account`

extends: -

is extended by: -

#### description

`Account` is responsible for managing the Ethereum account associated with the SingularityNET platform.
It provides methods for interacting with the MultiPartyEscrow contract, the SingularityNetToken contract, and
the Ethereum blockchain.

#### attributes

- `config` (dict): The configuration settings for the account. _Note_: In fact, this is the same config
from `SnetSDK`.
- `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.
- `token_contract` (Contract): An instance of the `Contract` class from the `web3` library for interacting
with the SingularityNET AGIX Token contract.
- `private_key` (str): The private key associated with the account.
- `signer_private_key` (str): The private key used for signing transactions.
- `address` (str): The Ethereum address associated with the account.
- `signer_address` (str): The Ethereum address used for signing transactions.
- `nonce` (int): The nonce value for the account.

#### methods

#### `__init__`

Initializes a new instance of the `Account` class.

###### args:

- `w3` (Web3): An instance of the `Web3` class.
- `config` (dict): A dictionary containing the configuration settings.
- `mpe_contract` (MPEContract): An instance of the `MPEContract` class.

###### returns:

- _None_

#### `_get_nonce`

Returns the next nonce for a transaction.

###### returns:

- The next nonce for a transaction. (int)

#### `_get_gas_price`

Calculates the gas price for a transaction.

Retrieves the current gas price from the Ethereum network using the web3 and increases it
according to a certain algorithm so that the transaction goes faster.

###### returns:

- The calculated gas price. (int)

#### `_send_signed_transaction`

Sends a signed transaction to the Ethereum blockchain.

Builds a transaction using the given contract function and arguments, signs it with the private key of the account,
and sends it to the Ethereum blockchain.

###### args:

- `contract_fn`: The contract function to be called.
- `*args`: The arguments to pass to the contract function.

###### returns:

- Hash of the sent transaction. (HexStr | str)

#### `send_transaction`

Sends a transaction by calling the given contract function with the provided arguments.

###### args:

- `contract_fn`: The contract function to be called.
- `*args`: The arguments to pass to the contract function.

###### returns:

- The transaction receipt indicating the success or failure of the transaction. (TxReceipt)

#### `_parse_receipt`

Parses the receipt of a transaction and returns the result as a JSON string.

###### args:

- `receipt` (TxReceipt): The receipt of the transaction.
- `event` (Event): The event to process the receipt with.
- `encoder` (JSONEncoder): The JSON encoder to use. Defaults to json.JSONEncoder.

###### returns:

- The result of processing the receipt as a JSON string. (str)

###### raises:

- TransactionError: If the transaction status is 0, indicating a failed transaction.

#### `escrow_balance`

Retrieves the escrow balance for the current account.

###### returns:

- The escrow balance in cogs. (int)

#### `deposit_to_escrow_account`

Deposit the specified amount of AGIX tokens in cogs into the MPE account.

###### args:

- `amount_in_cogs` (int): The amount of AGIX tokens in cogs to deposit.

###### returns:

- The transaction receipt of the transaction. (TxReceipt)

#### `approve_transfer`

Approves a transfer of a specified amount of AGIX tokens in cogs to the MPE contract.

###### args:

- `amount_in_cogs` (int): The amount of AGIX tokens in cogs to approve for transfer.

###### returns:

- The transaction receipt of the transaction. (TxReceipt)

#### `allowance`

Retrieves the allowance of the current account for the MPE contract.

###### returns:

- The allowance in cogs. (int)

75 changes: 75 additions & 0 deletions docs/main/client_lib_generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## module: sdk.client_lib_generator

[Link](https://github.com/singnet/snet-sdk-python/blob/master/snet/sdk/client_lib_generator.py) to GitHub

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`

extends: -

is extended by: -

#### description

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.
- `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`.
- `protodir` (str): The directory where the .proto files are located. Default is `~/.snet`.

#### methods

#### `__init__`

Initializes a new instance of the class. Initializes the attributes by arguments values.

###### 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.
- `org_id` (str): The organization ID of the service.
- `service_id` (str): The service ID.

###### returns:

- _None_

#### `generate_client_library`

Generates client library stub files based on specified organization and service ids, including:
- getting service metadata from Registry
- getting .proto file from IPFS
- 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.

Loading
Loading