fix: named ERC20Infomation

This commit is contained in:
Coline
2022-07-22 11:13:27 +02:00
parent d3b8cdcfdf
commit d5a8859ebf
4 changed files with 9 additions and 9 deletions

View File

@@ -9,7 +9,7 @@ from speculos.client import SpeculosClient, ApduException
from ethereum_client.ethereum_cmd_builder import EthereumCommandBuilder, InsType
from ethereum_client.exception import DeviceException
from ethereum_client.transaction import EIP712, PersonalTransaction, Transaction
from ethereum_client.plugin import ERC20_Information, Plugin
from ethereum_client.plugin import ERC20Information, Plugin
from ethereum_client.utils import parse_sign_response
@@ -59,7 +59,7 @@ class EthereumCommand:
except ApduException as error:
raise DeviceException(error_code=error.sw, ins=InsType.INS_PROVIDE_NFT_INFORMATION)
def provide_erc20_token_information(self, info: ERC20_Information):
def provide_erc20_token_information(self, info: ERC20Information):
try:
self.client._apdu_exchange(
self.builder.provide_erc20_token_information(info=info)

View File

@@ -5,7 +5,7 @@ import struct
from typing import List, Tuple, Union, Iterator, cast
from ethereum_client.transaction import EIP712, PersonalTransaction, Transaction
from ethereum_client.plugin import ERC20_Information, Plugin
from ethereum_client.plugin import ERC20Information, Plugin
from ethereum_client.utils import bip32_path_from_string
MAX_APDU_LEN: int = 255
@@ -124,7 +124,7 @@ class EthereumCommandBuilder:
p2=0x00,
cdata=b"")
def _same_header_builder(self, data: Union[Plugin, ERC20_Information], ins: int) -> bytes:
def _same_header_builder(self, data: Union[Plugin, ERC20Information], ins: int) -> bytes:
return self.serialize(cla=self.CLA,
ins=ins,
p1=0x00,
@@ -137,7 +137,7 @@ class EthereumCommandBuilder:
def provide_nft_information(self, plugin: Plugin) -> bytes:
return self._same_header_builder(plugin, InsType.INS_PROVIDE_NFT_INFORMATION)
def provide_erc20_token_information(self, info: ERC20_Information):
def provide_erc20_token_information(self, info: ERC20Information):
return self._same_header_builder(info, InsType.INS_PROVIDE_ERC20)
def get_public_key(self, bip32_path: str, display: bool = False) -> bytes:

View File

@@ -3,7 +3,7 @@ from typing import Union
from ethereum_client.utils import apdu_as_string, write_varint
class ERC20_Information:
class ERC20Information:
def __init__(self, erc20_ticker: string , addr: Union[str, bytes], nb_decimals: int, chainID: int, sign: str) -> None:
self.erc20_ticker: bytes = apdu_as_string(erc20_ticker)
self.addr: bytes = bytes.fromhex(addr[2:]) if isinstance(addr, str) else addr

View File

@@ -1,8 +1,8 @@
from ethereum_client.plugin import ERC20_Information
from ethereum_client.plugin import ERC20Information
import ethereum_client
def test_provide_erc20_token(cmd):
erc20_info = ERC20_Information(
erc20_info = ERC20Information(
erc20_ticker="5a5258",
addr="0xe41d2489571d322189246dafa5ebde1f4699f498",
nb_decimals=18,
@@ -17,7 +17,7 @@ def test_provide_erc20_token(cmd):
raise
def test_provide_erc20_token_error(cmd):
erc20_info = ERC20_Information(
erc20_info = ERC20Information(
erc20_ticker="5a5258",
addr="0xe41d2489571d322189246dafa5ebde1f4699f498",
nb_decimals=18,