From 8fa96760a57611d8cfdf12f176909f9b3d195a41 Mon Sep 17 00:00:00 2001 From: JonathanAmenechi <7217608+JonathanAmenechi@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:33:35 -0500 Subject: [PATCH 1/4] fix: use signer chain id when building 712 sigs --- py_clob_client/signing/eip712.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py_clob_client/signing/eip712.py b/py_clob_client/signing/eip712.py index be0e10f..6ea16ab 100644 --- a/py_clob_client/signing/eip712.py +++ b/py_clob_client/signing/eip712.py @@ -7,12 +7,13 @@ CLOB_VERSION = "1" MSG_TO_SIGN = "This message attests that I control the given wallet" -def get_clob_auth_domain(): +def get_clob_auth_domain(chain_id:int): return make_domain(name=CLOB_DOMAIN_NAME, version=CLOB_VERSION, chainId=1) def sign_clob_auth_message(signer: Signer, timestamp: int)-> str: clob_auth_msg = ClobAuth(address=signer.address, timestamp=str(timestamp), message=MSG_TO_SIGN) - auth_struct_hash = Web3.keccak(clob_auth_msg.signable_bytes(get_clob_auth_domain())) + chain_id = signer.get_chain_id() + auth_struct_hash = Web3.keccak(clob_auth_msg.signable_bytes(get_clob_auth_domain(chain_id))) return signer.sign(auth_struct_hash) From a453c72b14ac4f9a70bf6f15e900091c94bb71cc Mon Sep 17 00:00:00 2001 From: JonathanAmenechi <7217608+JonathanAmenechi@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:33:56 -0500 Subject: [PATCH 2/4] fix: use signer chain id when building 712 sigs --- py_clob_client/signing/eip712.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py_clob_client/signing/eip712.py b/py_clob_client/signing/eip712.py index 6ea16ab..86ea6dd 100644 --- a/py_clob_client/signing/eip712.py +++ b/py_clob_client/signing/eip712.py @@ -8,7 +8,7 @@ MSG_TO_SIGN = "This message attests that I control the given wallet" def get_clob_auth_domain(chain_id:int): - return make_domain(name=CLOB_DOMAIN_NAME, version=CLOB_VERSION, chainId=1) + return make_domain(name=CLOB_DOMAIN_NAME, version=CLOB_VERSION, chainId=chain_id) def sign_clob_auth_message(signer: Signer, timestamp: int)-> str: clob_auth_msg = ClobAuth(address=signer.address, timestamp=str(timestamp), message=MSG_TO_SIGN) From c8275f53e0d3d1dc6e3bae8e956ad2e148d857b8 Mon Sep 17 00:00:00 2001 From: JonathanAmenechi <7217608+JonathanAmenechi@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:54:02 -0500 Subject: [PATCH 3/4] fix: update examples --- examples/create_api_key.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/create_api_key.py b/examples/create_api_key.py index 677c700..ed27a13 100644 --- a/examples/create_api_key.py +++ b/examples/create_api_key.py @@ -1,9 +1,15 @@ +from dotenv import load_dotenv +import os + from py_clob_client.client import ClobClient +load_dotenv() + def main(): host = "http://localhost:8080" - key = "0x" - client = ClobClient(host, key=key, chain_id=42) + key = os.getenv("PK") + chain_id = 80001 + client = ClobClient(host, key=key, chain_id=chain_id) print(client.create_api_key()) From 7ed2387e70b86a30ff6e5c87e8edb64a35f03814 Mon Sep 17 00:00:00 2001 From: JonathanAmenechi <7217608+JonathanAmenechi@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:57:27 -0500 Subject: [PATCH 4/4] fix: bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 569f4b4..9256c67 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="py_clob_client", - version="0.0.5", + version="0.0.6", author="Jonathan Amenechi", author_email="jonathanamenechi@gmail.com", description="Python client for the Polymarket CLOB",