1
1
import * as torii from "@dojoengine/torii-client" ;
2
- import { Account , Signature , StarknetDomain , TypedData } from "starknet" ;
2
+ import type { Account , Signature , StarknetDomain , TypedData } from "starknet" ;
3
3
4
- import {
4
+ import type {
5
5
GetParams ,
6
6
SchemaType ,
7
7
SDK ,
@@ -14,7 +14,7 @@ import {
14
14
import { intoEntityKeysClause } from "./convertClauseToEntityKeysClause" ;
15
15
import { parseEntities } from "./parseEntities" ;
16
16
import { parseHistoricalEvents } from "./parseHistoricalEvents" ;
17
- import { ToriiQueryBuilder } from "./toriiQueryBuilder" ;
17
+ import type { ToriiQueryBuilder } from "./toriiQueryBuilder" ;
18
18
import { generateTypedData } from "./generateTypedData" ;
19
19
20
20
export * from "./types" ;
@@ -34,6 +34,11 @@ export async function createClient(
34
34
return await torii . createClient ( config ) ;
35
35
}
36
36
37
+ export const defaultClientConfig : Partial < torii . ClientConfig > = {
38
+ toriiUrl : "http://localhost:8080" ,
39
+ relayUrl : "/ip4/127.0.0.1/tcp/9090" ,
40
+ } ;
41
+
37
42
/**
38
43
* Initializes the SDK with the provided configuration and schema.
39
44
*
@@ -43,7 +48,11 @@ export async function createClient(
43
48
export async function init < T extends SchemaType > (
44
49
options : SDKConfig
45
50
) : Promise < SDK < T > > {
46
- const client = await createClient ( options . client ) ;
51
+ const clientConfig = {
52
+ ...defaultClientConfig ,
53
+ ...options . client ,
54
+ } as torii . ClientConfig ;
55
+ const client = await createClient ( clientConfig ) ;
47
56
48
57
return {
49
58
client,
@@ -137,6 +146,7 @@ export async function init<T extends SchemaType>(
137
146
const parsedData = historical
138
147
? parseHistoricalEvents < T > ( data )
139
148
: parseEntities < T > ( data ) ;
149
+
140
150
callback ( {
141
151
data : parsedData as ToriiResponse <
142
152
T ,
0 commit comments