Skip to content

Commit

Permalink
Merge pull request #396 from ZigaMr/ZigaMr/sapphirepy/signed-queries
Browse files Browse the repository at this point in the history
Add signed data/leash/signature to eth_call data
  • Loading branch information
ZigaMr authored Oct 16, 2024
2 parents 5240107 + 6d0b95b commit a4024f8
Show file tree
Hide file tree
Showing 9 changed files with 284 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 a4024f8

Please sign in to comment.