Skip to content

Commit

Permalink
# This is a combination of 7 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

Add signed data/leash/signature to eth_call data

# This is the commit message #2:

Remove duplicated RPC calls, fix msg format for eip712

# This is the commit message #3:

Testing

# This is the commit message #4:

Fix schema for signed queries

# This is the commit message #5:

Fix type annotations for mypy, add compiled test contract, add unsigned data call test

# This is the commit message #6:

Fix pylint errors

# This is the commit message #7:

Add build and tests to ci-test.yaml

Add setuptools for wheel compilation

Fix wheel name

Move py test to ci-test.yaml

Fix file path format, separate pytest and unittest commands

Update signature condition on provided account parameter, add default None account argument
  • Loading branch information
ZigaMr committed Oct 16, 2024
1 parent 5240107 commit 46e13ee
Show file tree
Hide file tree
Showing 9 changed files with 285 additions and 79 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,46 @@ jobs:

- name: Test JS client
run: pnpm test:unit

test-client-py:
name: test-client-py
runs-on: ubuntu-latest
services:
sapphire-localnet-ci:
image: ghcr.io/oasisprotocol/sapphire-localnet:latest
ports:
- 8545:8545
options: >-
--rm
--health-cmd="test -f /CONTAINER_READY"
--health-start-period=90s
defaults:
run:
working-directory: ./clients/py
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- name: Build sapphirepy .whl file
run: |
pip3 install --user -r requirements.txt
pip3 install --user -r requirements.dev.txt
make
- name: Install sapphirepy .whl file
run: |
pip3 install --user -r requirements.txt
pip3 install --user dist/sapphire.py-0.3.0-py3-none-any.whl
- name: Python client tests
working-directory: clients/py
run: |
python3 -mpip install --user -r requirements.txt
python3 -mpip install --user -r requirements.dev.txt
python3 -munittest discover
pytest sapphirepy/tests/
5 changes: 0 additions & 5 deletions .github/workflows/contracts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ jobs:
uses: actions/checkout@v4
- name: Install jq
run: sudo apt install -y jq
- name: Python client tests
working-directory: clients/py
run: |
python3 -mpip install --user -r requirements.txt
python3 -munittest discover
- name: Install Node.js
uses: actions/setup-node@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions clients/py/requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ py-solc-x
mypy
pylint
ruff
setuptools
pytest
13 changes: 13 additions & 0 deletions clients/py/sapphirepy/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ def encrypt(self, plaintext: bytes):
}
return cbor2.dumps(envelope, canonical=True)

def make_envelope(self, plaintext: bytes):
ciphertext, nonce = self._encrypt_calldata(plaintext)
envelope = {
'body': {
'pk': self.ephemeral_pubkey,
'data': ciphertext,
'nonce': nonce,
'epoch': self.epoch
},
'format': FORMAT_ENCRYPTED_X25519DEOXYSII
}
return envelope

def _decode_inner(self, plaintext:bytes) -> bytes:
inner_result = cast(ResultInner, cbor2.loads(plaintext))
if inner_result.get('ok', None) is not None:
Expand Down
Loading

0 comments on commit 46e13ee

Please sign in to comment.