MockingMagician / coinbase-pro-sdk

Coinbase Pro API SDK - Communicate easily with the Coinbase Pro API in PHP
https://mockingmagician.github.io/coinbase-pro-sdk/
MIT License
22 stars 8 forks source link

Error while calling it from queue #30

Closed imyuvii closed 2 years ago

imyuvii commented 2 years ago

Serialization of 'Closure' is not allowed

We are building a trading bot, so we have are calling CoinbaseFacade from Queue, It throws "Serialization of 'Closure' is not allowed", Not sure how to fix that

image

MockingMagician commented 2 years ago

Hello @imyuvii

Can you show me the whole example? CoinbaseFacade doesn't need to be serialized, as it contains only static methods, so why serialize an object that can't be parameterized (immutable).

Can you explain your logic and purpose?

MockingMagician commented 2 years ago

Hello @imyuvii

I think that in reality, it is coibaseApi that you serialize, indeed it includes closures which are not natively serializable in php. I implemented a fix to work around the problem, the error should not appear anymore in case of serialization. Make sure you update the package in your project.

Anyway, in case of serialization of such an object, and in the context of cryptos, I strongly advise you to encrypt your serialization to reduce the exposure of sensitive data.

A better solution, in my opinion, seems to be to instantiate your object from your queue task. If you provide me with more details of your code, I could guide you in this direction; and if not, linearization should not be a problem anymore.

Kind regards