Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lighter/signer_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from lighter.models.resp_send_tx import RespSendTx
from lighter.models.resp_send_tx_batch import RespSendTxBatch
from lighter.transactions import CreateOrder, CancelOrder, Withdraw, CreateGroupedOrders
from lighter.libc import free

CODE_OK = 200

Expand Down Expand Up @@ -99,8 +98,10 @@ def decode_and_free(ptr: Any) -> Optional[str]:
return c_str.decode('utf-8')
return None
finally:
# Free the memory allocated by the C library
free(ptr)
# Free the memory using the signer's own Free function to ensure
# the same C runtime that allocated the memory also frees it.
# This is critical on Windows where different CRTs have separate heaps.
__signer.Free(ptr)


def __populate_shared_library_functions(signer):
Expand Down Expand Up @@ -174,6 +175,9 @@ def __populate_shared_library_functions(signer):
signer.SignApproveIntegrator.argtypes = [ctypes.c_longlong, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong]
signer.SignApproveIntegrator.restype = SignedTxResponse

signer.Free.argtypes = [ctypes.c_void_p]
signer.Free.restype = None


def get_signer():
# check if singleton exists already
Expand Down
Binary file modified lighter/signers/lighter-signer-darwin-arm64.dylib
Binary file not shown.
1 change: 1 addition & 0 deletions lighter/signers/lighter-signer-darwin-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ extern SignedTxResponse SignUpdateMargin(int cMarketIndex, long long cUSDCAmount
extern SignedTxResponse SignStakeAssets(long long cStakingPoolIndex, long long cShareAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex);
extern SignedTxResponse SignUnstakeAssets(long long cStakingPoolIndex, long long cShareAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex);
extern SignedTxResponse SignApproveIntegrator(long long cIntegratorIndex, uint32_t cMaxPerpsTakerFee, uint32_t cMaxPerpsMakerFee, uint32_t cMaxSpotTakerFee, uint32_t cMaxSpotMakerFee, long long cApprovalExpiry, long long cNonce, int cApiKeyIndex, long long cAccountIndex);
extern void Free(void* ptr);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions lighter/signers/lighter-signer-linux-amd64.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extern SignedTxResponse SignUpdateMargin(int cMarketIndex, long long int cUSDCAm
extern SignedTxResponse SignStakeAssets(long long int cStakingPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern SignedTxResponse SignUnstakeAssets(long long int cStakingPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern SignedTxResponse SignApproveIntegrator(long long int cIntegratorIndex, uint32_t cMaxPerpsTakerFee, uint32_t cMaxPerpsMakerFee, uint32_t cMaxSpotTakerFee, uint32_t cMaxSpotMakerFee, long long int cApprovalExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern void Free(void* ptr);

#ifdef __cplusplus
}
Expand Down
Binary file modified lighter/signers/lighter-signer-linux-amd64.so
Binary file not shown.
1 change: 1 addition & 0 deletions lighter/signers/lighter-signer-linux-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extern SignedTxResponse SignUpdateMargin(int cMarketIndex, long long int cUSDCAm
extern SignedTxResponse SignStakeAssets(long long int cStakingPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern SignedTxResponse SignUnstakeAssets(long long int cStakingPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern SignedTxResponse SignApproveIntegrator(long long int cIntegratorIndex, uint32_t cMaxPerpsTakerFee, uint32_t cMaxPerpsMakerFee, uint32_t cMaxSpotTakerFee, uint32_t cMaxSpotMakerFee, long long int cApprovalExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern void Free(void* ptr);

#ifdef __cplusplus
}
Expand Down
Binary file modified lighter/signers/lighter-signer-linux-arm64.so
Binary file not shown.
Binary file modified lighter/signers/lighter-signer-windows-amd64.dll
Binary file not shown.
1 change: 1 addition & 0 deletions lighter/signers/lighter-signer-windows-amd64.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extern __declspec(dllexport) SignedTxResponse SignUpdateMargin(int cMarketIndex,
extern __declspec(dllexport) SignedTxResponse SignStakeAssets(long long int cStakingPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern __declspec(dllexport) SignedTxResponse SignUnstakeAssets(long long int cStakingPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern __declspec(dllexport) SignedTxResponse SignApproveIntegrator(long long int cIntegratorIndex, uint32_t cMaxPerpsTakerFee, uint32_t cMaxPerpsMakerFee, uint32_t cMaxSpotTakerFee, uint32_t cMaxSpotMakerFee, long long int cApprovalExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex);
extern __declspec(dllexport) void Free(void* ptr);

#ifdef __cplusplus
}
Expand Down
Loading