@@ -10,57 +10,90 @@ import { setupWorld } from "./defineContractSystems.ts";
1010
1111import { DojoProvider } from "@dojoengine/core" ;
1212import { BurnerManager } from "@dojoengine/create-burner" ;
13- import { Account , RpcProvider , wallet } from "starknet" ;
14- import { createClientComponents } from "./createClientComponent.ts" ;
13+ import { Account , RpcProvider } from "starknet" ;
14+ import {
15+ ClientComponents ,
16+ createClientComponents ,
17+ } from "./createClientComponent.ts" ;
1518
1619export type SetupResult = Awaited < ReturnType < typeof setup > > ;
1720export type IDojo = Awaited < ReturnType < typeof setup > > ;
1821
1922export async function setup ( { ...config } : Config ) {
2023 // torii client
21- const toriiClient = await torii . createClient ( {
22- rpcUrl : config . rpcUrl ,
23- toriiUrl : config . toriiUrl ,
24- relayUrl : "" ,
25- worldAddress : config . manifest . world . address || "" ,
26- } ) ;
24+ let toriiClient = null ;
25+ try {
26+ toriiClient = await torii . createClient ( {
27+ rpcUrl : config . rpcUrl ,
28+ toriiUrl : config . toriiUrl ,
29+ relayUrl : "" ,
30+ worldAddress : config . manifest . world . address || "" ,
31+ } ) ;
32+ } catch ( e ) {
33+ console . error ( "Failed to create torii client:" , e ) ;
34+ throw e ;
35+ }
2736
2837 // create contract components
29- const contractModels = createClientComponents ( {
30- contractComponents : defineContractComponents ( world ) ,
31- } ) ;
38+ let contractModels = null ;
39+ try {
40+ contractModels = createClientComponents ( {
41+ contractComponents : defineContractComponents ( world ) ,
42+ } ) ;
43+ } catch ( e ) {
44+ console . error ( "Failed to create contract components:" , e ) ;
45+ throw e ;
46+ }
3247
3348 // create client components
3449 const { models : clientModels } = models ( { contractModels } ) ;
3550
3651 // fetch all existing entities from torii
37- const sync = await getSyncEntities (
38- toriiClient ,
39- contractModels as any ,
40- [ ] ,
41- 1000
42- ) ;
52+ let sync = null ;
53+ try {
54+ sync = await getSyncEntities (
55+ toriiClient ,
56+ contractModels as any ,
57+ [ ] ,
58+ 1000
59+ ) ;
60+ } catch ( e ) {
61+ console . error ( "Failed to fetch sync:" , e ) ;
62+ throw e ;
63+ }
4364
44- const client = await setupWorld (
45- new DojoProvider ( config . manifest , config . rpcUrl ) ,
46- config
47- ) ;
65+ let client = null ;
66+ try {
67+ client = await setupWorld (
68+ new DojoProvider ( config . manifest , config . rpcUrl ) ,
69+ config
70+ ) ;
71+ } catch ( e ) {
72+ console . error ( "Failed to create client:" , e ) ;
73+ throw e ;
74+ }
4875
4976 const rpcProvider = new RpcProvider ( {
5077 nodeUrl : config . rpcUrl ,
5178 } ) ;
5279
53- const burnerManager = new BurnerManager ( {
54- masterAccount : new Account (
55- rpcProvider ,
56- config . masterAddress ,
57- config . masterPrivateKey
58- ) ,
59- feeTokenAddress : config . feeTokenAddress ,
60- accountClassHash : config . accountClassHash ,
80+ let burnerManager = null ;
81+ try {
82+ burnerManager = new BurnerManager ( {
83+ masterAccount : new Account (
84+ rpcProvider ,
85+ config . masterAddress ,
86+ config . masterPrivateKey
87+ ) ,
88+ feeTokenAddress : config . feeTokenAddress ,
89+ accountClassHash : config . accountClassHash ,
6190
62- rpcProvider,
63- } ) ;
91+ rpcProvider,
92+ } ) ;
93+ } catch ( e ) {
94+ console . log ( "Failed to create burner manager:" , e ) ;
95+ throw e ;
96+ }
6497
6598 try {
6699 await burnerManager . init ( ) ;
@@ -72,7 +105,7 @@ export async function setup({ ...config }: Config) {
72105 }
73106 const actions = systems ( {
74107 client,
75- clientModels,
108+ clientModels : clientModels as ClientComponents ,
76109 contractComponents : contractModels ,
77110 } ) ;
78111 const account = burnerManager . getActiveAccount ( ) ;
0 commit comments