UNPKG

@dojoengine/sdk

Version:

Dojo SDK: Build onchain and provable apps faster

2 lines 923 B
import{Z as o,v as r}from"./chunk-W7BJBH43.js";import*as a from"@dojoengine/torii-wasm";async function g(d){let c={...o,...d.client},n=new a.ToriiClient(c);return{getEntities:async t=>r((await n.getEntities(t)).items),getEvents:async t=>{let e=await n.getEventMessages(t);return r(e.items)},subscribeEntities:async(t,e)=>[r((await n.getEntities(t)).items),n.onEntityUpdated(t.clause,void 0,(y,s)=>{try{if(e){let i=r([s]);e({data:i})}}catch(i){e&&e({error:i instanceof Error?i:new Error(String(i))})}})],subscribeEvents:async(t,e)=>{if(t.no_hashed_keys&&t.clause&&!Object.hasOwn(t.clause,"Keys"))throw new Error("For subscription, you need to include entity ids");return[r((await n.getEventMessages(t)).items),n.onEventMessageUpdated(t.clause,void 0,(y,s)=>{try{if(e){let i=r([s]);e({data:i})}}catch(i){e&&e({error:i instanceof Error?i:new Error(String(i))})}})]}}}export{g as init}; //# sourceMappingURL=experimental.js.map