We've just merged some breaking changes for the Python SDK.
As you might have noticed, the GO SDK was updated a while ago, changing the interface.
Major changes on that side include:
each sign operation returns the TxType, TxInfo & TxHash
each sign operation receives two new arguments: account_index & api_key_index
These changes allow the Python SDK to support multiple accounts & API keys easier.
Changes have been made to the Python SDK to accommodate the changes, as well as updated examples.
Now, both the examples and the SignerClient use multiple API keys by default.
Note that the SignerClient is tied to one account index. You can create multiple instances of SignerClient.
The shared library is designed as a singleton so that there will be just one instance of it, so it's loaded just once.
You can instance a SignerClient as follows:
client = lighter.SignerClient(
url="https://mainnet.zklighter.elliot.ai",
account_index=...,
api_private_keys={
3: "c180...",
4: "ef13...",
...
}
)
HTTP calls should not be affected by these changes.
For WS operations, which use sign_create_order for example, directly, you'll need to update the list of returned values.
Each sign_ operation returns a tuple of (TxType, TxInfo, TxHash, error).
On how to use these values to send the transaction, please refer to the ./examples/create_modify_cancel_order_ws.py.
It includes example on nonce management and sending the transactions.
Specifically for WS operations, the fact that you have access to the TxHash might allow you to track your transaction easier, in an async way.