Skip to content

Commit

Permalink
Alignment with main project
Browse files Browse the repository at this point in the history
  • Loading branch information
macnablocky committed Mar 14, 2024
2 parents 65a782c + f4dce2a commit 1ab0d26
Show file tree
Hide file tree
Showing 251 changed files with 10,492 additions and 2,630 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ build
dist

#cache
cache
cache

#docker databases
docker-db
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
"singleQuote": true,
"printWidth": 80,
"arrowParens": "always",
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.sol",
"options": {
"semi": true,
"printWidth": 80,
"explicitTypes": "always"
"explicitTypes": "always",
"parser": "solidity-parse"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# yarn lockfile v1


yarn-path ".yarn/releases/yarn-1.19.0.cjs"
yarn-path ".yarn/releases/yarn-1.19.0.cjs"
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
| | | | |
| --- | --- | --- | --- |
| [![Lint Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-lint.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-lint.yaml) | [![Protocol Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-core.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-core.yaml) | [![Python SDK Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-python-sdk.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-python-sdk.yaml) | [![Node.js SDK Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-node-sdk.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-node-sdk.yaml) |
| [![Subgraph Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-subgraph.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-subgraph.yaml) | [![Fortune Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-fortune.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-fortune.yaml) | [![Escrow Dashboard Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-dashboard-ui.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-dashboard-ui.yaml) | [![Faucet Server Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-faucet-server.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-faucet-server.yaml) |
| [![Meta Code Verify Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-meta-code-verify.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-meta-code-verify.yaml) | | | |
| [![Subgraph Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-subgraph.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-subgraph.yaml) | [![Dashboard UI Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-dashboard-ui.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-dashboard-ui.yaml) | [![Faucet Server Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-faucet-server.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-faucet-server.yaml) | [![Meta Code Verify Check](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-meta-code-verify.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/ci-test-meta-code-verify.yaml) |
| [![Core NPM Publish](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-core.yaml/badge.svg?event=release)](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-core.yaml) | [![Python SDK Publish](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-python-sdk.yaml/badge.svg?event=release)](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-python-sdk.yaml) | [![Node.js SDK Publish](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-node-sdk.yaml/badge.svg?event=release)](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-node-sdk.yaml) | [![Subgraph Deploy](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-subgraph.yaml/badge.svg?branch=main)](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-subgraph.yaml) |
| [![Contract Deploy](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-deploy-contracts.yaml/badge.svg?event=workflow_dispatch)](https://github.com/humanprotocol/human-protocol/actions/workflows/cd-deploy-contracts.yaml) | | | |

Expand Down Expand Up @@ -48,14 +47,14 @@ The contribution guidelines are as per the CONTRIBUTING.MD file.
│ │ ├── faucet-server # Faucet server
│ │ ├── fortune # Fortune application
│ │ ├── job-launcher # Job launcher server, and UI
│ │ ├── human-app # Human App server
│ │ ├── meta-code-verify # Browser extensions to verify code
│ │ │ running in the browser against a
│ │ │ published manifest
│ │ ├── reputation-oracle # Reputation Oracle server
│ ├── core # EVM compatible smart contracts for HUMAN
│ ├── examples
│ │ ├── cvat # An open source annotation tool for labeling video and images
│ │ ├── fortune # An example application that combines all the core
│ │ │ components of HUMAN
│ ├── sdk
│ │ ├── python
│ │ │ ├── human-protocol-sdk # Python SDK to interact with Human Protocol
Expand Down
9 changes: 4 additions & 5 deletions docs/sdk/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

### Added

- **Added OperatorUtils module:** new module for fetching leaders and operators information.
- **Add function to get the encryption public key:** get public key function added to KVStore client.

### Changed

- **Update ethers version:** update ethers to version 6.
- **Update cancel escrow method:** return transaction hash and refunded amount.
- **Rename set url function of KVStore client:** function renamed to be descriptive. This function sets the url and the hash
- **Rename get url function of KVStore client:** function renamed to be descriptive. This function gets the url and verifies the hash of the content.
- **Convert operators config keys to snake_case:** use snake_case as standard.

### Deprecated

### Removed

- **Remove staking utils module:** the methods from this module have been moved into the new OperatorUtils module.

### Fixed

### Security
Expand Down
16 changes: 16 additions & 0 deletions docs/sdk/python/human_protocol_sdk.constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ Enum for chain IDs.

#### SKALE *= 1273227453*

### *class* human_protocol_sdk.constants.KVStoreKeys(value)

Bases: `Enum`

Enum for KVStore keys

#### fee *= 'fee'*

#### public_key *= 'public_key'*

#### role *= 'role'*

#### url *= 'url'*

#### webhook_url *= 'webhook_url'*

### *class* human_protocol_sdk.constants.Role(value)

Bases: `Enum`
Expand Down
44 changes: 35 additions & 9 deletions docs/sdk/python/human_protocol_sdk.kvstore.kvstore_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ Gets the value of a key-value pair in the contract.
role = kvstore_client.get('0x62dD51230A30401C455c8398d06F85e4EaB6309f', 'Role')
```

#### get_url(address, key='url')
#### get_file_url_and_verify_hash(address, key='url')

Gets the URL value of the given entity.
Gets the URL value of the given entity, and verify its hash.

* **Parameters:**
* **address** (`str`) – Address from which to get the URL value.
Expand All @@ -106,12 +106,38 @@ Gets the URL value of the given entity.
w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
kvstore_client = KVStoreClient(w3)

url = kvstore_client.get_url(
url = kvstore_client.get_file_url_and_verify_hash(
'0x62dD51230A30401C455c8398d06F85e4EaB6309f'
)
linkedin_url = kvstore_client.get_url(
linkedin_url = kvstore_client.get_file_url_and_verify_hash(
'0x62dD51230A30401C455c8398d06F85e4EaB6309f',
'linkedinUrl'
'linkedin_url'
)
```
* **Return type:**
`str`

#### get_public_key(address)

Gets the public key of the given entity, and verify its hash.

* **Parameters:**
**address** (`str`) – Address from which to get the public key.
* **Return public_key:**
The public key of the given address if exists, and the content is valid
* **Example:**
```python
from eth_typing import URI
from web3 import Web3
from web3.providers.auto import load_provider_from_uri

from human_protocol_sdk.kvstore import KVStoreClient

w3 = Web3(load_provider_from_uri(URI("http://localhost:8545")))
kvstore_client = KVStoreClient(w3)

public_key = kvstore_client.get_public_key(
'0x62dD51230A30401C455c8398d06F85e4EaB6309f'
)
```
* **Return type:**
Expand Down Expand Up @@ -192,9 +218,9 @@ Sets multiple key-value pairs in the contract.
kvstore_client.set_bulk(keys, values)
```

#### set_url(url, key='url', tx_options=None)
#### set_file_url_and_hash(url, key='url', tx_options=None)

Sets a URL value for the address that submits the transaction.
Sets a URL value for the address that submits the transaction, and its hash.

* **Parameters:**
* **url** (`str`) – URL to set
Expand Down Expand Up @@ -228,8 +254,8 @@ Sets a URL value for the address that submits the transaction.
(w3, gas_payer) = get_w3_with_priv_key('YOUR_PRIVATE_KEY')
kvstore_client = KVStoreClient(w3)

kvstore_client.set_url('http://localhost')
kvstore_client.set_url('https://linkedin.com/me', 'linkedinUrl')
kvstore_client.set_file_url_and_hash('http://localhost')
kvstore_client.set_file_url_and_hash('https://linkedin.com/me', 'linkedin_url')
```

### *exception* human_protocol_sdk.kvstore.kvstore_client.KVStoreClientError
Expand Down
5 changes: 3 additions & 2 deletions docs/sdk/python/human_protocol_sdk.kvstore.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ This module allows the contract interaction with the key value storage on chain.
* [`KVStoreClient`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient)
* [`KVStoreClient.__init__()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.__init__)
* [`KVStoreClient.get()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.get)
* [`KVStoreClient.get_url()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.get_url)
* [`KVStoreClient.get_file_url_and_verify_hash()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.get_file_url_and_verify_hash)
* [`KVStoreClient.get_public_key()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.get_public_key)
* [`KVStoreClient.set()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.set)
* [`KVStoreClient.set_bulk()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.set_bulk)
* [`KVStoreClient.set_url()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.set_url)
* [`KVStoreClient.set_file_url_and_hash()`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClient.set_file_url_and_hash)
* [`KVStoreClientError`](human_protocol_sdk.kvstore.kvstore_client.md#human_protocol_sdk.kvstore.kvstore_client.KVStoreClientError)
4 changes: 2 additions & 2 deletions docs/sdk/python/human_protocol_sdk.legacy_encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Cipher algorithm defintion.

alias of `AES`

#### ELLIPTIC_CURVE*: `EllipticCurve`* *= <cryptography.hazmat.primitives.asymmetric.ec.SECP256K1 object>*
#### ELLIPTIC_CURVE *: `EllipticCurve`* *= <cryptography.hazmat.primitives.asymmetric.ec.SECP256K1 object>*

Elliptic curve definition.

Expand All @@ -35,7 +35,7 @@ Cipher mode definition.

alias of `CTR`

#### PUBLIC_KEY_LEN*: `int`* *= 64*
#### PUBLIC_KEY_LEN *: `int`* *= 64*

Length of public keys: 512 bit keys in uncompressed form, without
format byte
Expand Down
6 changes: 6 additions & 0 deletions docs/sdk/python/human_protocol_sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@
* [`ChainId.POLYGON_MUMBAI`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.ChainId.POLYGON_MUMBAI)
* [`ChainId.RINKEBY`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.ChainId.RINKEBY)
* [`ChainId.SKALE`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.ChainId.SKALE)
* [`KVStoreKeys`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.KVStoreKeys)
* [`KVStoreKeys.fee`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.KVStoreKeys.fee)
* [`KVStoreKeys.public_key`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.KVStoreKeys.public_key)
* [`KVStoreKeys.role`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.KVStoreKeys.role)
* [`KVStoreKeys.url`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.KVStoreKeys.url)
* [`KVStoreKeys.webhook_url`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.KVStoreKeys.webhook_url)
* [`Role`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.Role)
* [`Role.exchange_oracle`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.Role.exchange_oracle)
* [`Role.job_launcher`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.Role.job_launcher)
Expand Down
1 change: 1 addition & 0 deletions docs/sdk/python/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pip install human-protocol-sdk[agreement]
* [Submodules](human_protocol_sdk.md#submodules)
* [human_protocol_sdk.constants module](human_protocol_sdk.constants.md)
* [`ChainId`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.ChainId)
* [`KVStoreKeys`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.KVStoreKeys)
* [`Role`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.Role)
* [`Status`](human_protocol_sdk.constants.md#human_protocol_sdk.constants.Status)
* [human_protocol_sdk.filter module](human_protocol_sdk.filter.md)
Expand Down
6 changes: 3 additions & 3 deletions docs/sdk/typescript/classes/base.BaseEthersClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This class is used as a base class for other clients making on-chain calls.

#### Defined in

[base.ts:20](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/base.ts#L20)
[base.ts:20](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/base.ts#L20)

## Properties

Expand All @@ -60,7 +60,7 @@ This class is used as a base class for other clients making on-chain calls.

#### Defined in

[base.ts:12](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/base.ts#L12)
[base.ts:12](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/base.ts#L12)

___

Expand All @@ -70,4 +70,4 @@ ___

#### Defined in

[base.ts:11](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/base.ts#L11)
[base.ts:11](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/base.ts#L11)
12 changes: 6 additions & 6 deletions docs/sdk/typescript/classes/encryption.Encryption.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Constructor for the Encryption class.

#### Defined in

[encryption.ts:53](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L53)
[encryption.ts:53](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L53)

## Properties

Expand All @@ -91,7 +91,7 @@ Constructor for the Encryption class.

#### Defined in

[encryption.ts:46](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L46)
[encryption.ts:46](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L46)

## Methods

Expand Down Expand Up @@ -140,7 +140,7 @@ const resultMessage = await encription.decrypt('message');

#### Defined in

[encryption.ts:180](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L180)
[encryption.ts:180](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L180)

___

Expand Down Expand Up @@ -176,7 +176,7 @@ const resultMessage = await encription.sign('message');

#### Defined in

[encryption.ts:217](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L217)
[encryption.ts:217](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L217)

___

Expand Down Expand Up @@ -238,7 +238,7 @@ const resultMessage = await encription.signAndEncrypt('message', publicKeys);

#### Defined in

[encryption.ts:129](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L129)
[encryption.ts:129](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L129)

___

Expand All @@ -263,4 +263,4 @@ Builds an Encryption instance by decrypting the private key from an encrypted pr

#### Defined in

[encryption.ts:64](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L64)
[encryption.ts:64](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L64)
10 changes: 5 additions & 5 deletions docs/sdk/typescript/classes/encryption.EncryptionUtils.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const result = await EncriptionUtils.encrypt('message', publicKeys);

#### Defined in

[encryption.ts:422](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L422)
[encryption.ts:422](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L422)

___

Expand Down Expand Up @@ -157,7 +157,7 @@ const result = await EncriptionUtils.generateKeyPair(name, email, passphrase);

#### Defined in

[encryption.ts:360](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L360)
[encryption.ts:360](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L360)

___

Expand Down Expand Up @@ -189,7 +189,7 @@ const signedData = await EncriptionUtils.getSignedData('message');

#### Defined in

[encryption.ts:317](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L317)
[encryption.ts:317](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L317)

___

Expand Down Expand Up @@ -237,7 +237,7 @@ if (isEncrypted) {

#### Defined in

[encryption.ts:471](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L471)
[encryption.ts:471](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L471)

___

Expand Down Expand Up @@ -282,4 +282,4 @@ const result = await EncriptionUtils.verify('message', publicKey);

#### Defined in

[encryption.ts:284](https://github.com/humanprotocol/human-protocol/blob/87747676/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L284)
[encryption.ts:284](https://github.com/humanprotocol/human-protocol/blob/48066071/packages/sdk/typescript/human-protocol-sdk/src/encryption.ts#L284)
Loading

0 comments on commit 1ab0d26

Please sign in to comment.