Skip to content

Commit 65cf745

Browse files
feat: init
1 parent c656e95 commit 65cf745

14 files changed

+745
-58
lines changed

packages/sdk/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

packages/sdk/.npmignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*
2+
3+
!dist/**
4+
!package.json
5+
!readme.md
6+
!changelog.md

packages/sdk/CHANGELOG.md

+282
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
## 0.6.124 (2024-04-24)
7+
8+
**Note:** Version bump only for package @dojoengine/utils
9+
10+
11+
12+
13+
14+
## 0.6.123 (2024-04-24)
15+
16+
**Note:** Version bump only for package @dojoengine/utils
17+
18+
19+
20+
21+
22+
## [0.6.122](https://github.com/dojoengine/dojo.js/compare/v0.6.121...v0.6.122) (2024-04-09)
23+
24+
25+
26+
## [0.6.121](https://github.com/dojoengine/dojo.js/compare/v0.6.12...v0.6.121) (2024-04-07)
27+
28+
29+
30+
## [0.6.12](https://github.com/dojoengine/dojo.js/compare/v0.6.11...v0.6.12) (2024-04-05)
31+
32+
33+
34+
## [0.6.11](https://github.com/dojoengine/dojo.js/compare/v0.6.1...v0.6.11) (2024-04-05)
35+
36+
37+
38+
## [0.6.1](https://github.com/dojoengine/dojo.js/compare/v0.6.1-alpha.11...v0.6.1) (2024-04-04)
39+
40+
41+
### Bug Fixes
42+
43+
* new torii event bugfix ([c0ea7d9](https://github.com/dojoengine/dojo.js/commit/c0ea7d9859863474e2bdd37d5193aa52853b8ce4))
44+
45+
46+
47+
## [0.6.1-alpha.1](https://github.com/dojoengine/dojo.js/compare/v0.6.0-alpha.5...v0.6.1-alpha.1) (2024-04-02)
48+
49+
50+
51+
## [0.6.1-alpha.0](https://github.com/dojoengine/dojo.js/compare/v0.6.0-alpha.0...v0.6.1-alpha.0) (2024-03-08)
52+
53+
54+
### Bug Fixes
55+
56+
* imports ([e68462a](https://github.com/dojoengine/dojo.js/commit/e68462ab7f84ad532129200e1f485fad5803e51c))
57+
58+
59+
60+
# [0.6.0-alpha.0](https://github.com/dojoengine/dojo.js/compare/v0.5.9...v0.6.0-alpha.0) (2024-03-07)
61+
62+
63+
### Bug Fixes
64+
65+
* update snjs ([7240474](https://github.com/dojoengine/dojo.js/commit/72404740ed651e1d2204582fccc5903524ac40d7))
66+
67+
68+
69+
# [0.6.0-alpha.5](https://github.com/dojoengine/dojo.js/compare/v0.6.0-alpha.2...v0.6.0-alpha.5) (2024-04-01)
70+
71+
72+
73+
## [0.6.1-alpha.0](https://github.com/dojoengine/dojo.js/compare/v0.6.0-alpha.0...v0.6.1-alpha.0) (2024-03-08)
74+
75+
76+
### Bug Fixes
77+
78+
* imports ([e68462a](https://github.com/dojoengine/dojo.js/commit/e68462ab7f84ad532129200e1f485fad5803e51c))
79+
80+
81+
82+
# [0.6.0-alpha.0](https://github.com/dojoengine/dojo.js/compare/v0.5.9...v0.6.0-alpha.0) (2024-03-07)
83+
84+
85+
### Bug Fixes
86+
87+
* remove types ([4f9787d](https://github.com/dojoengine/dojo.js/commit/4f9787d67c6a849cbd5713170f535904c640d23e))
88+
* update snjs ([7240474](https://github.com/dojoengine/dojo.js/commit/72404740ed651e1d2204582fccc5903524ac40d7))
89+
90+
91+
### Features
92+
93+
* update deps ([b9e47f4](https://github.com/dojoengine/dojo.js/commit/b9e47f45e0d4ccb18b1b7062e60924ad213b1c8b))
94+
95+
96+
97+
## [0.5.9](https://github.com/dojoengine/dojo.js/compare/v0.5.8...v0.5.9) (2024-02-17)
98+
99+
100+
101+
## [0.5.8](https://github.com/dojoengine/dojo.js/compare/v0.5.7...v0.5.8) (2024-02-09)
102+
103+
104+
105+
## [0.5.7](https://github.com/dojoengine/dojo.js/compare/v0.5.6...v0.5.7) (2024-02-08)
106+
107+
108+
109+
## [0.5.6](https://github.com/dojoengine/dojo.js/compare/v0.5.5...v0.5.6) (2024-02-03)
110+
111+
112+
### Bug Fixes
113+
114+
* ci lint ([285d094](https://github.com/dojoengine/dojo.js/commit/285d094116a0e777e6abde6b097aec725fa05ba9))
115+
116+
117+
118+
## [0.5.5](https://github.com/dojoengine/dojo.js/compare/v0.5.4...v0.5.5) (2024-02-01)
119+
120+
121+
122+
## [0.5.4](https://github.com/dojoengine/dojo.js/compare/v0.5.3...v0.5.4) (2024-02-01)
123+
124+
125+
126+
## [0.5.3](https://github.com/dojoengine/dojo.js/compare/v0.5.2...v0.5.3) (2024-01-30)
127+
128+
129+
130+
## [0.5.2](https://github.com/dojoengine/dojo.js/compare/v0.5.1...v0.5.2) (2024-01-29)
131+
132+
133+
134+
## [0.5.1](https://github.com/dojoengine/dojo.js/compare/v0.5.0...v0.5.1) (2024-01-28)
135+
136+
137+
138+
# [0.5.0](https://github.com/dojoengine/dojo.js/compare/v0.3.5...v0.5.0) (2024-01-27)
139+
140+
141+
142+
## [0.3.5](https://github.com/dojoengine/dojo.js/compare/v0.3.4...v0.3.5) (2024-01-24)
143+
144+
145+
146+
## [0.3.4](https://github.com/dojoengine/dojo.js/compare/v0.3.3...v0.3.4) (2024-01-16)
147+
148+
149+
150+
## [0.3.3](https://github.com/dojoengine/dojo.js/compare/v0.3.2...v0.3.3) (2024-01-12)
151+
152+
153+
154+
## [0.3.2](https://github.com/dojoengine/dojo.js/compare/v0.2.10...v0.3.2) (2024-01-10)
155+
156+
157+
158+
## [0.2.10](https://github.com/dojoengine/dojo.js/compare/v0.2.9...v0.2.10) (2023-12-23)
159+
160+
161+
162+
## [0.2.9](https://github.com/dojoengine/dojo.js/compare/v0.2.8...v0.2.9) (2023-12-19)
163+
164+
165+
166+
## [0.2.8](https://github.com/dojoengine/dojo.js/compare/v0.2.7...v0.2.8) (2023-12-19)
167+
168+
169+
170+
## [0.2.7](https://github.com/dojoengine/dojo.js/compare/v0.2.6...v0.2.7) (2023-12-19)
171+
172+
173+
174+
## [0.2.6](https://github.com/dojoengine/dojo.js/compare/v0.2.5...v0.2.6) (2023-12-18)
175+
176+
177+
178+
# [0.2.0](https://github.com/dojoengine/dojo.js/compare/v0.2.0-alpha.0...v0.2.0) (2023-12-14)
179+
180+
181+
182+
# [0.2.0-alpha.0](https://github.com/dojoengine/dojo.js/compare/v0.1.62-alpha.0...v0.2.0-alpha.0) (2023-12-13)
183+
184+
185+
186+
## [0.1.62-alpha.0](https://github.com/dojoengine/dojo.js/compare/v0.1.61-alpha.0...v0.1.62-alpha.0) (2023-12-13)
187+
188+
189+
190+
## [0.1.61-alpha.0](https://github.com/dojoengine/dojo.js/compare/v0.1.60...v0.1.61-alpha.0) (2023-12-13)
191+
192+
193+
194+
## [0.1.60](https://github.com/dojoengine/dojo.js/compare/v0.1.58...v0.1.60) (2023-12-12)
195+
196+
197+
198+
## [0.1.55](https://github.com/dojoengine/dojo.js/compare/v0.1.54...v0.1.55) (2023-11-24)
199+
200+
201+
202+
## [0.1.54](https://github.com/dojoengine/dojo.js/compare/v0.1.53...v0.1.54) (2023-11-24)
203+
204+
205+
206+
## [0.1.53](https://github.com/dojoengine/dojo.js/compare/v0.1.52...v0.1.53) (2023-11-24)
207+
208+
209+
210+
## [0.1.51](https://github.com/dojoengine/dojo.js/compare/v0.1.50...v0.1.51) (2023-11-24)
211+
212+
213+
214+
## [0.1.50](https://github.com/dojoengine/dojo.js/compare/v0.1.49...v0.1.50) (2023-11-22)
215+
216+
217+
218+
## [0.1.49](https://github.com/dojoengine/dojo.js/compare/v0.1.48...v0.1.49) (2023-11-22)
219+
220+
221+
222+
## [0.1.48](https://github.com/dojoengine/dojo.js/compare/v0.1.47...v0.1.48) (2023-11-22)
223+
224+
225+
226+
## [0.1.47](https://github.com/dojoengine/dojo.js/compare/v0.1.46...v0.1.47) (2023-11-22)
227+
228+
229+
230+
## [0.1.46](https://github.com/dojoengine/dojo.js/compare/v0.1.45...v0.1.46) (2023-11-22)
231+
232+
233+
234+
## [0.1.45](https://github.com/dojoengine/dojo.js/compare/v0.1.44...v0.1.45) (2023-11-22)
235+
236+
237+
238+
## [0.1.44](https://github.com/dojoengine/dojo.js/compare/v0.1.43...v0.1.44) (2023-11-22)
239+
240+
241+
242+
## [0.1.43](https://github.com/dojoengine/dojo.js/compare/v0.1.42...v0.1.43) (2023-11-20)
243+
244+
245+
246+
## [0.1.42](https://github.com/dojoengine/dojo.js/compare/v0.1.38...v0.1.42) (2023-11-11)
247+
248+
249+
250+
## [0.1.34](https://github.com/dojoengine/dojo.js/compare/v0.1.33...v0.1.34) (2023-11-03)
251+
252+
253+
254+
## [0.1.31](https://github.com/dojoengine/dojo.js/compare/v0.1.30...v0.1.31) (2023-10-31)
255+
256+
257+
258+
## [0.1.29](https://github.com/dojoengine/dojo.js/compare/v0.1.28...v0.1.29) (2023-10-19)
259+
260+
261+
262+
## [0.1.27](https://github.com/dojoengine/dojo.js/compare/v0.1.26...v0.1.27) (2023-10-18)
263+
264+
265+
266+
## [0.1.26](https://github.com/dojoengine/dojo.js/compare/v0.1.25...v0.1.26) (2023-10-18)
267+
268+
269+
270+
## [0.1.25](https://github.com/dojoengine/dojo.js/compare/v0.1.24...v0.1.25) (2023-10-17)
271+
272+
273+
274+
## [0.1.22](https://github.com/dojoengine/dojo.js/compare/v0.1.21...v0.1.22) (2023-10-17)
275+
276+
277+
278+
## [0.1.21](https://github.com/dojoengine/dojo.js/compare/v0.1.2...v0.1.21) (2023-10-16)
279+
280+
281+
282+
## 0.1.2 (2023-10-07)

packages/sdk/package.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "@dojoengine/utils",
3+
"version": "1.0.0-alpha.11",
4+
"description": "dojo: utils ",
5+
"author": "dojo",
6+
"license": "MIT",
7+
"main": "dist/index.js",
8+
"type": "module",
9+
"scripts": {
10+
"build": "tsup --dts-resolve",
11+
"test": "vitest run",
12+
"coverage": "vitest run --coverage"
13+
},
14+
"exports": {
15+
".": {
16+
"import": "./dist/index.js",
17+
"types": "./dist/index.d.ts"
18+
}
19+
},
20+
"devDependencies": {
21+
"@types/elliptic": "^6.4.14",
22+
"@vitest/coverage-v8": "^1.3.0",
23+
"tsup": "^8.0.1",
24+
"typescript": "^5.5.4",
25+
"vitest": "^1.1.0"
26+
},
27+
"peerDependencies": {
28+
"starknet": "6.11.0"
29+
},
30+
"dependencies": {
31+
"@dojoengine/torii-client": "workspace:*",
32+
"@dojoengine/recs": "2.0.13",
33+
"@latticexyz/utils": "^2.0.0-next.11",
34+
"mathjs": "^12.0.0",
35+
"micro-starknet": "^0.2.3"
36+
}
37+
}
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { describe, it, expect, vi } from "vitest";
2+
import * as torii from "@dojoengine/torii-client";
3+
import { init } from "../index";
4+
5+
describe("SDK Client Tests", () => {
6+
const mockClient = {
7+
onEntityUpdated: vi.fn(),
8+
};
9+
10+
const mockCreateClient = vi
11+
.spyOn(torii, "createClient")
12+
.mockResolvedValue(mockClient);
13+
14+
const initOptions: torii.ClientConfig = {
15+
rpcUrl: "http://localhost:8545",
16+
toriiUrl: "http://localhost:8080",
17+
relayUrl: "http://localhost:8081",
18+
worldAddress: "0x1234567890abcdef",
19+
};
20+
21+
it("should create a client with the correct configuration", async () => {
22+
const { client } = await init(initOptions);
23+
expect(mockCreateClient).toHaveBeenCalledWith({
24+
rpcUrl: initOptions.rpcUrl,
25+
toriiUrl: initOptions.toriiUrl,
26+
relayUrl: initOptions.relayUrl,
27+
worldAddress: initOptions.worldAddress,
28+
});
29+
expect(client).toBe(mockClient);
30+
});
31+
32+
it("should subscribe to a query and handle updates", async () => {
33+
const { client, subscribeQuery } = await init(initOptions);
34+
const mockCallback = vi.fn();
35+
const query = { key: "value" };
36+
37+
const mockSubscription = {
38+
unsubscribe: vi.fn(),
39+
};
40+
41+
mockClient.onEntityUpdated.mockImplementation((clauses, callback) => {
42+
callback({ data: [{ id: 1 }] });
43+
return mockSubscription;
44+
});
45+
46+
const subscription = await subscribeQuery(query, mockCallback);
47+
48+
expect(mockClient.onEntityUpdated).toHaveBeenCalled();
49+
expect(mockCallback).toHaveBeenCalledWith({ data: [{ id: 1 }] });
50+
expect(subscription).toBe(mockSubscription);
51+
});
52+
});

0 commit comments

Comments
 (0)