Merge pull request #480 from LedgerHQ/fbe/fix_python_client_job_trigger

Fix python-client github job trigger
This commit is contained in:
François Beutin
2023-10-27 18:03:13 +02:00
committed by GitHub
5 changed files with 17 additions and 11 deletions

View File

@@ -7,11 +7,11 @@ on:
- develop - develop
- master - master
paths: paths:
- ./client/** - client/**
- .github/workflows/python-client.yml - .github/workflows/python-client.yml
pull_request: pull_request:
paths: paths:
- ./client/** - client/**
- .github/workflows/python-client.yml - .github/workflows/python-client.yml
jobs: jobs:

View File

@@ -2,7 +2,7 @@ import rlp
from enum import IntEnum from enum import IntEnum
from ragger.backend import BackendInterface from ragger.backend import BackendInterface
from ragger.utils import RAPDU from ragger.utils import RAPDU
from typing import List, Optional from typing import List, Optional, Union
from .command_builder import CommandBuilder from .command_builder import CommandBuilder
from .eip712 import EIP712FieldType from .eip712 import EIP712FieldType
@@ -13,13 +13,16 @@ from .tlv import format_tlv
WEI_IN_ETH = 1e+18 WEI_IN_ETH = 1e+18
GWEI_IN_ETH = 1e+9 GWEI_IN_ETH = 1e+9
class TxData: class TxData:
selector: bytes selector: bytes
parameters: list[bytes] parameters: list[bytes]
def __init__(self, selector: bytes, params: list[bytes]): def __init__(self, selector: bytes, params: list[bytes]):
self.selector = selector self.selector = selector
self.parameters = params self.parameters = params
class StatusWord(IntEnum): class StatusWord(IntEnum):
OK = 0x9000 OK = 0x9000
ERROR_NO_INFO = 0x6a00 ERROR_NO_INFO = 0x6a00
@@ -30,6 +33,7 @@ class StatusWord(IntEnum):
CONDITION_NOT_SATISFIED = 0x6985 CONDITION_NOT_SATISFIED = 0x6985
REF_DATA_NOT_FOUND = 0x6a88 REF_DATA_NOT_FOUND = 0x6a88
class DomainNameTag(IntEnum): class DomainNameTag(IntEnum):
STRUCTURE_TYPE = 0x01 STRUCTURE_TYPE = 0x01
STRUCTURE_VERSION = 0x02 STRUCTURE_VERSION = 0x02
@@ -121,7 +125,7 @@ class EthAppClient:
gas_limit: int, gas_limit: int,
destination: bytes, destination: bytes,
amount: float, amount: float,
data: TxData): data: Optional[TxData]):
tx.append(int(gas_price * GWEI_IN_ETH)) tx.append(int(gas_price * GWEI_IN_ETH))
tx.append(gas_limit) tx.append(gas_limit)
tx.append(destination) tx.append(destination)
@@ -143,8 +147,8 @@ class EthAppClient:
destination: bytes, destination: bytes,
amount: float, amount: float,
chain_id: int, chain_id: int,
data: TxData = None): data: Optional[TxData] = None):
tx = list() tx: List[Union[int, bytes]] = list()
tx.append(nonce) tx.append(nonce)
tx = self._sign_common(tx, gas_price, gas_limit, destination, amount, data) tx = self._sign_common(tx, gas_price, gas_limit, destination, amount, data)
tx.append(chain_id) tx.append(chain_id)
@@ -161,9 +165,9 @@ class EthAppClient:
gas_limit: int, gas_limit: int,
destination: bytes, destination: bytes,
amount: float, amount: float,
data: TxData = None, data: Optional[TxData] = None,
access_list = list()): access_list=list()):
tx = list() tx: List[Union[int, bytes]] = list()
tx.append(chain_id) tx.append(chain_id)
tx.append(nonce) tx.append(nonce)
tx.append(int(max_prio_gas_price * GWEI_IN_ETH)) tx.append(int(max_prio_gas_price * GWEI_IN_ETH))

View File

@@ -182,12 +182,12 @@ class CommandBuilder:
P2Type.FILTERING_FIELD_NAME, P2Type.FILTERING_FIELD_NAME,
self._eip712_filtering_send_name(name, sig)) self._eip712_filtering_send_name(name, sig))
def set_external_plugin(self, plugin_name: str, contract_address: bytes, method_selelector: bytes, sig: bytes) -> bytes: def set_external_plugin(self, plugin_name: str, contract_address: bytes, selector: bytes, sig: bytes) -> bytes:
data = bytearray() data = bytearray()
data.append(len(plugin_name)) data.append(len(plugin_name))
data += self._string_to_bytes(plugin_name) data += self._string_to_bytes(plugin_name)
data += contract_address data += contract_address
data += method_selelector data += selector
data += sig data += sig
return self._serialize(InsType.EXTERNAL_PLUGIN_SETUP, return self._serialize(InsType.EXTERNAL_PLUGIN_SETUP,

View File

@@ -14,6 +14,7 @@ def challenge(data: bytes) -> int:
assert len(data) == 4 assert len(data) == 4
return int.from_bytes(data, "big") return int.from_bytes(data, "big")
def pk_addr(data: bytes, has_chaincode: bool = False): def pk_addr(data: bytes, has_chaincode: bool = False):
idx = 0 idx = 0

View File

@@ -1,4 +1,5 @@
import sha3 import sha3
def get_selector_from_function(fn: str) -> bytes: def get_selector_from_function(fn: str) -> bytes:
return sha3.keccak_256(fn.encode()).digest()[0:4] return sha3.keccak_256(fn.encode()).digest()[0:4]