staratlasmeta / factory

Star Atlas Factory for constructing Transactions targeting Solana on-chain programs
https://www.npmjs.com/package/@staratlas/factory
Apache License 2.0
37 stars 15 forks source link

GmEventService is not a constructor | Getting all open orders for multiple assets at once #85

Closed skullnbonesdao closed 2 years ago

skullnbonesdao commented 2 years ago

Problem

Get all open orders for assets at once. Cause running getOpenOrdersForAssets in a loop causes to many request and my current solution is using a rate-limit.

Solution

getOpenOrdersForAssets(connection: Connection, assetMint: PublicKey[], programId: PublicKey): Promise<[OrderAccountItemAsset])[]>

where

export interface OrderAccountItemAsset {
  assetMint: PublicKey;
  orders: OrderAccountItem[];
}

Alternatives Considered

rate limiting?

Notes

If there is already a way please let me know. Thanks S&B

skullnbonesdao commented 2 years ago

....[update]

So I found the GmOrderbookService class by now which should do exactly what i want.

But trying to implement it gives me the following error:

Uncaught (in promise) TypeError: anchor_1.Wallet is not a constructor
    GmEventService GmEventService.ts:48
    GmOrderbookService GmOrderbookService.ts:46

error_gmOrderBookService

CodeSandbox:

redspatula commented 2 years ago

I can confirm I have the same exact error with GmOrderbookService

MikeLuDev commented 2 years ago

Hi @skullnbonesdao @redspatula - we're taking a look into this. Thanks for the report!

MikeLuDev commented 2 years ago

Quick update on this is that it appears that this issue is specific to the browser environment. Running the service inside of a Node.js server, for example, with the same code linked above works just fine.

Obviously this is a client side package though so we should expect it to work properly in the browser, so we'll keep digging :+1:

skullnbonesdao commented 2 years ago

Don't really know if this is the exact issue here but it seems like its related (since a import gets converted into a require when running npm build ) maybe this helps:

There seems to be also a update in the anchor package since there is an issue with that exact import/require statement:

"@project-serum/anchor": "^0.24.2" => 0.25.0

Hope this helps :pray:

redspatula commented 2 years ago

Thanks for the update. I no longer have that bug. Site is up and running now again =D

MikeLuDev commented 2 years ago

Awesome, thanks for the confirmation @redspatula. Closing this issue as completed for now but feel free to re-flag if anyone else is still experiencing it.