Skip to content

Commit 51039e4

Browse files
feat: cleanup SDK
1 parent 2f3d287 commit 51039e4

File tree

5 files changed

+31
-121
lines changed

5 files changed

+31
-121
lines changed

packages/sdk/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@dojoengine/sdk",
33
"version": "1.0.0-alpha.16",
4-
"description": "Dojo SDK for interacting with the Dojo provable game engine.",
4+
"description": "Dojo SDK: Build onchain and provable apps faster",
55
"author": "Dojo Team",
66
"license": "MIT",
77
"main": "dist/index.js",
@@ -31,17 +31,17 @@
3131
"tsup": "^8.3.0",
3232
"typescript": "^5.6.2",
3333
"vite": "^3.2.11",
34-
"vitest": "^1.6.0"
34+
"vitest": "^1.6.0",
35+
"vite-plugin-wasm": "^3.3.0"
3536
},
3637
"peerDependencies": {
3738
"starknet": "6.11.0"
3839
},
3940
"dependencies": {
4041
"@dojoengine/create-burner": "workspace:*",
4142
"@dojoengine/torii-client": "workspace:*",
42-
"axios": "^0.27.2",
43+
"@dojoengine/core": "workspace:*",
4344
"immer": "^10.1.1",
44-
"vite-plugin-wasm": "^3.3.0",
4545
"zustand": "^4.5.5"
4646
},
4747
"repository": {
@@ -60,6 +60,6 @@
6060
"torii"
6161
],
6262
"engines": {
63-
"node": ">=14.0.0"
63+
"node": ">=18.0.0"
6464
}
6565
}

packages/sdk/src/convertQuerytoClause.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
// packages/sdk/src/convertQuerytoClause.ts
22

33
import * as torii from "@dojoengine/torii-client";
4-
import {
5-
QueryType,
6-
SchemaType,
7-
LogicalOperator,
8-
SubscriptionQueryType,
9-
} from "./types";
10-
import {
11-
convertQueryToEntityKeyClauses,
12-
convertQueryToKeysClause,
13-
} from "./convertQueryToEntityKeyClauses";
4+
import { QueryType, SchemaType, SubscriptionQueryType } from "./types";
5+
import { convertQueryToEntityKeyClauses } from "./convertQueryToEntityKeyClauses";
146

157
/**
168
* Converts a query object into a Torii clause.

packages/sdk/src/index.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
import * as torii from "@dojoengine/torii-client";
2+
import { Account, Signature, StarknetDomain, TypedData } from "starknet";
23

34
import { getEntities } from "./getEntities";
45
import { getEventMessages } from "./getEventMessages";
56
import { subscribeEntityQuery } from "./subscribeEntityQuery";
67
import { subscribeEventQuery } from "./subscribeEventQuery";
7-
import { SchemaType, SDK, UnionOfModelData } from "./types";
8-
import { Account, Signature, StarknetDomain, TypedData } from "starknet";
8+
import { SchemaType, SDK, SDKConfig, UnionOfModelData } from "./types";
99

1010
export * from "./types";
1111
export * from "./state";
1212

13-
interface SDKConfig {
14-
client: torii.ClientConfig;
15-
domain: StarknetDomain;
16-
}
17-
1813
/**
1914
* Creates a new Torii client instance.
2015
*

packages/sdk/src/types.ts

+16-83
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import * as torii from "@dojoengine/torii-client";
44
import { Account, StarknetDomain, TypedData } from "starknet";
5-
import { AccountInterface, RpcProvider } from "starknet";
65

76
/**
87
* Utility type to ensure at least one property is present
@@ -82,17 +81,12 @@ export type QueryOptions = {
8281
entityId?: string;
8382
};
8483

85-
/**
86-
* Logical operators for combining multiple conditions
87-
*/
88-
export type LogicalOperator = "AND" | "OR";
89-
9084
/**
9185
* Recursively defines the conditions for the `where` clause.
9286
*/
9387
export type WhereCondition<TModel> =
9488
| {
95-
[key in LogicalOperator]?: Array<WhereCondition<TModel>>;
89+
[key in torii.LogicalOperator]?: Array<WhereCondition<TModel>>;
9690
}
9791
| {
9892
[P in keyof TModel]?: {
@@ -341,81 +335,20 @@ export interface SDK<T extends SchemaType> {
341335
sendMessage: (data: TypedData, account: Account) => Promise<void>;
342336
}
343337

344-
export type BurnerStorage = {
345-
[address: string]: BurnerRecord;
346-
};
347-
348-
export type BurnerRecord = {
349-
chainId: string;
350-
privateKey: string;
351-
publicKey: string;
352-
deployTx: string;
353-
masterAccount: string;
354-
active: boolean;
355-
accountIndex?: number;
356-
metadata?: any;
357-
};
358-
359-
export type Burner = {
360-
address: string;
361-
active: boolean;
362-
masterAccount?: string;
363-
accountIndex?: number;
364-
};
365-
366-
export interface BurnerManagerOptions {
367-
masterAccount: Account;
368-
accountClassHash: string;
369-
feeTokenAddress: string;
370-
rpcProvider: RpcProvider;
371-
}
372-
373-
export interface BurnerAccount {
374-
create: (options?: BurnerCreateOptions) => void;
375-
list: () => Burner[];
376-
get: (address: string) => AccountInterface;
377-
remove: (address: string) => void;
378-
account: Account;
379-
select: (address: string) => void;
380-
deselect: () => void;
381-
isDeploying: boolean;
382-
clear: () => void;
383-
count: number;
384-
copyToClipboard: () => Promise<void>;
385-
applyFromClipboard: () => Promise<void>;
386-
getActiveAccount?: () => Account | null;
387-
generateAddressFromSeed?: (options?: BurnerCreateOptions) => string;
388-
checkIsDeployed: (address: string, deployTx?: string) => Promise<boolean>;
389-
}
390-
391-
export interface BurnerCreateOptions {
392-
secret?: string;
393-
index?: number;
394-
metadata?: any;
395-
prefundedAmount?: string;
396-
maxFee?: number;
397-
}
398-
399-
export interface BurnerKeys {
400-
privateKey: string;
401-
publicKey: string;
402-
address: string;
403-
}
404-
405-
export type Predeployed = Burner & { name?: string };
406-
407-
export type PredeployedStorage = {
408-
[address: string]: PredeployedAccount;
409-
};
338+
/**
339+
* Configuration interface for the SDK.
340+
*/
341+
export interface SDKConfig {
342+
/**
343+
* Configuration for the Torii client.
344+
* This includes settings such as the endpoint URL, authentication details, etc.
345+
*/
346+
client: torii.ClientConfig;
410347

411-
export interface PredeployedManagerOptions {
412-
rpcProvider: RpcProvider;
413-
predeployedAccounts: PredeployedAccount[];
348+
/**
349+
* The Starknet domain configuration.
350+
* This is used for generating typed data and signing messages.
351+
* It typically includes details like the chain ID, name, and version.
352+
*/
353+
domain: StarknetDomain;
414354
}
415-
416-
export type PredeployedAccount = {
417-
name?: string;
418-
address: string;
419-
privateKey: string;
420-
active: boolean;
421-
};

pnpm-lock.yaml

+6-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)