Skip to content

Commit 73bf33c

Browse files
committed
update SDK
1 parent df90927 commit 73bf33c

File tree

4 files changed

+225
-69
lines changed

4 files changed

+225
-69
lines changed

packages/engine/src/client/types.gen.ts

Lines changed: 175 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ export type BatchResultItemEncodeResultSuccessItemEngineError =
116116
message: string;
117117
type: "VAULT_ERROR";
118118
}
119+
| {
120+
error: IawError;
121+
type: "IAW_ERROR";
122+
}
119123
| {
120124
message: string;
121125
type: "RPC_CONFIG_ERROR";
@@ -199,6 +203,10 @@ export type BatchResultItemReadResultSuccessItemEngineError =
199203
message: string;
200204
type: "VAULT_ERROR";
201205
}
206+
| {
207+
error: IawError;
208+
type: "IAW_ERROR";
209+
}
202210
| {
203211
message: string;
204212
type: "RPC_CONFIG_ERROR";
@@ -291,6 +299,10 @@ export type BatchResultItemSignResultDataEngineError =
291299
message: string;
292300
type: "VAULT_ERROR";
293301
}
302+
| {
303+
error: IawError;
304+
type: "IAW_ERROR";
305+
}
294306
| {
295307
message: string;
296308
type: "RPC_CONFIG_ERROR";
@@ -325,6 +337,36 @@ export type BatchResultItemSignResultDataEngineError =
325337
};
326338
};
327339

340+
/**
341+
* Collection of results from multiple contract encode operations
342+
*/
343+
export type BatchResultsEncodeResultSuccessItem = {
344+
/**
345+
* Array of results, one for each input contract call
346+
*/
347+
result: Array<BatchResultItemEncodeResultSuccessItemEngineError>;
348+
};
349+
350+
/**
351+
* Collection of results from multiple contract encode operations
352+
*/
353+
export type BatchResultsReadResultSuccessItem = {
354+
/**
355+
* Array of results, one for each input contract call
356+
*/
357+
result: Array<BatchResultItemReadResultSuccessItemEngineError>;
358+
};
359+
360+
/**
361+
* Collection of results from multiple contract encode operations
362+
*/
363+
export type BatchResultsSignResultData = {
364+
/**
365+
* Array of results, one for each input contract call
366+
*/
367+
result: Array<BatchResultItemSignResultDataEngineError>;
368+
};
369+
328370
/**
329371
* # Bytes
330372
* Used to represent "bytes". This is a 0x prefixed hex string.
@@ -603,6 +645,34 @@ export type Erc4337SigningOptions = EntrypointAndFactoryDetailsDeserHelper & {
603645
*/
604646
export type ExecutionOptions = BaseExecutionOptions & SpecificExecutionOptions;
605647

648+
/**
649+
* Error types for IAW operations
650+
*/
651+
export type IawError =
652+
| {
653+
type: "API_ERROR";
654+
}
655+
| {
656+
message: string;
657+
type: "SERIALIZATION_ERROR";
658+
}
659+
| {
660+
error: SerializableReqwestError;
661+
type: "NETWORK_ERROR";
662+
}
663+
| {
664+
type: "AUTH_ERROR";
665+
}
666+
| (ThirdwebError & {
667+
type: "THIRDWEB_ERROR";
668+
})
669+
| {
670+
type: "UNEXPECTED_ERROR";
671+
}
672+
| (UserOpError & {
673+
type: "USER_OP_ERROR";
674+
});
675+
606676
/**
607677
* # InnerTransaction
608678
* This is the actual encoded inner transaction data that will be sent to the blockchain.
@@ -768,6 +838,76 @@ export type SendTransactionRequest = {
768838
webhookOptions?: Array<WebhookOptions> | null;
769839
};
770840

841+
export type SerializableReqwestError =
842+
| {
843+
Builder: {
844+
message: string;
845+
url?: string | null;
846+
};
847+
}
848+
| {
849+
Request: {
850+
message: string;
851+
url?: string | null;
852+
};
853+
}
854+
| {
855+
Timeout: {
856+
message: string;
857+
url?: string | null;
858+
};
859+
}
860+
| {
861+
Connect: {
862+
message: string;
863+
url?: string | null;
864+
};
865+
}
866+
| {
867+
Redirect: {
868+
message: string;
869+
url?: string | null;
870+
};
871+
}
872+
| {
873+
ClientError: {
874+
status: number;
875+
message: string;
876+
url?: string | null;
877+
};
878+
}
879+
| {
880+
ServerError: {
881+
status: number;
882+
message: string;
883+
url?: string | null;
884+
};
885+
}
886+
| {
887+
Body: {
888+
message: string;
889+
url?: string | null;
890+
};
891+
}
892+
| {
893+
Decode: {
894+
message: string;
895+
url?: string | null;
896+
};
897+
}
898+
| {
899+
Upgrade: {
900+
message: string;
901+
url?: string | null;
902+
};
903+
}
904+
| {
905+
Unknown: {
906+
message: string;
907+
url?: string | null;
908+
};
909+
};
910+
771911
/**
772912
* Request to sign messages
773913
*/
@@ -844,45 +984,34 @@ export type SpecificExecutionOptions =
844984
type: "ERC4337";
845985
});
846986

847-
export type SuccessResponseBatchResultsEncodeResultSuccessItem = {
848-
/**
849-
* Collection of results from multiple contract encode operations
850-
*/
851-
result: {
852-
/**
853-
* Array of results, one for each input contract call
854-
*/
855-
results: Array<BatchResultItemEncodeResultSuccessItemEngineError>;
856-
};
857-
};
858-
859-
export type SuccessResponseBatchResultsReadResultSuccessItem = {
860-
/**
861-
* Collection of results from multiple contract encode operations
862-
*/
987+
export type SuccessResponseQueuedTransactionsResponse = {
863988
result: {
864-
/**
865-
* Array of results, one for each input contract call
866-
*/
867-
results: Array<BatchResultItemReadResultSuccessItemEngineError>;
989+
transactions: Array<QueuedTransaction>;
868990
};
869991
};
870992

871-
export type SuccessResponseBatchResultsSignResultData = {
872-
/**
873-
* Collection of results from multiple contract encode operations
874-
*/
875-
result: {
876-
/**
877-
* Array of results, one for each input contract call
878-
*/
879-
results: Array<BatchResultItemSignResultDataEngineError>;
880-
};
881-
};
993+
export type ThirdwebError =
994+
| {
995+
error: ThirdwebSerializationError;
996+
type: "SERIALIZATION_ERROR";
997+
}
998+
| {
999+
value: string;
1000+
message: string;
1001+
type: "URL_PARSE_ERROR";
1002+
}
1003+
| {
1004+
message: string;
1005+
type: "HTTP_CLIENT_BACKEND_ERROR";
1006+
}
1007+
| {
1008+
error: SerializableReqwestError;
1009+
type: "HTTP_ERROR";
1010+
};
8821011

883-
export type SuccessResponseQueuedTransactionsResponse = {
884-
result: {
885-
transactions: Array<QueuedTransaction>;
1012+
export type ThirdwebSerializationError = {
1013+
HeaderValue: {
1014+
value: string;
8861015
};
8871016
};
8881017

@@ -934,6 +1063,13 @@ export type TypedDataDomainDef = {
9341063
*/
9351064
export type U256Def = string;
9361065

1066+
/**
1067+
* Error type for UserOp operations
1068+
*/
1069+
export type UserOpError = {
1070+
type: "UNEXPECTED_ERROR";
1071+
};
1072+
9371073
export type Value = unknown;
9381074

9391075
export type WebhookOptions = {
@@ -1033,7 +1169,7 @@ export type SignMessageResponses = {
10331169
/**
10341170
* Successfully signed messages
10351171
*/
1036-
200: SuccessResponseBatchResultsSignResultData;
1172+
200: BatchResultsSignResultData;
10371173
};
10381174

10391175
export type SignMessageResponse =
@@ -1059,7 +1195,7 @@ export type SignTypedDataResponses = {
10591195
/**
10601196
* Successfully signed typed data
10611197
*/
1062-
200: SuccessResponseBatchResultsSignResultData;
1198+
200: BatchResultsSignResultData;
10631199
};
10641200

10651201
export type SignTypedDataResponse =
@@ -1079,7 +1215,7 @@ export type ReadContractResponses = {
10791215
/**
10801216
* Successfully read contract data
10811217
*/
1082-
200: SuccessResponseBatchResultsReadResultSuccessItem;
1218+
200: BatchResultsReadResultSuccessItem;
10831219
};
10841220

10851221
export type ReadContractResponse =
@@ -1099,7 +1235,7 @@ export type EncodeContractResponses = {
10991235
/**
11001236
* Successfully encoded contract calls
11011237
*/
1102-
200: SuccessResponseBatchResultsEncodeResultSuccessItem;
1238+
200: BatchResultsEncodeResultSuccessItem;
11031239
};
11041240

11051241
export type EncodeContractResponse =
@@ -1560,5 +1696,5 @@ export type SearchActivityLogsResponse =
15601696
SearchActivityLogsResponses[keyof SearchActivityLogsResponses];
15611697

15621698
export type ClientOptions = {
1563-
baseUrl: "https://engine.thirdweb-dev.com" | (string & {});
1699+
baseUrl: "http://localhost:3001" | (string & {});
15641700
};

packages/engine/src/configure.ts

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,51 @@ import type { Config } from "./client/client/index.js";
22
import { client } from "./client/client.gen.js";
33

44
export type EngineClientOptions = {
5-
readonly clientId?: string;
6-
readonly secretKey?: string;
5+
readonly clientId?: string;
6+
readonly secretKey?: string;
77
};
88

99
export function configure(
10-
options: EngineClientOptions & { override?: Config },
10+
options: EngineClientOptions & { override?: Config },
1111
) {
12-
client.setConfig({
13-
bodySerializer: stringify,
14-
headers: {
15-
...(options.clientId && { "x-client-id": options.clientId }),
16-
...(options.secretKey && { "x-secret-key": options.secretKey }),
17-
},
18-
...(options.override ?? {}),
19-
});
12+
client.setConfig({
13+
bodySerializer: stringify,
14+
headers: {
15+
...(options.clientId && { "x-client-id": options.clientId }),
16+
...(options.secretKey && { "x-secret-key": options.secretKey }),
17+
},
18+
...(options.override ?? {}),
19+
});
2020
}
2121

2222
function stringify(
23-
// biome-ignore lint/suspicious/noExplicitAny: JSON.stringify signature
24-
value: any,
25-
// biome-ignore lint/suspicious/noExplicitAny: JSON.stringify signature
26-
replacer?: ((this: any, key: string, value: any) => any) | null,
27-
space?: string | number,
23+
// biome-ignore lint/suspicious/noExplicitAny: JSON.stringify signature
24+
value: any,
25+
// biome-ignore lint/suspicious/noExplicitAny: JSON.stringify signature
26+
replacer?: ((this: any, key: string, value: any) => any) | null,
27+
space?: string | number,
2828
) {
29-
const res = JSON.stringify(
30-
value,
31-
(key, value_) => {
32-
const value__ = typeof value_ === "bigint" ? value_.toString() : value_;
33-
return typeof replacer === "function" ? replacer(key, value__) : value__;
34-
},
35-
space,
36-
);
37-
return res;
29+
const res = JSON.stringify(
30+
value,
31+
(key, value_) => {
32+
const value__ = typeof value_ === "bigint" ? value_.toString() : value_;
33+
return typeof replacer === "function" ? replacer(key, value__) : value__;
34+
},
35+
space,
36+
);
37+
return res;
38+
}
39+
40+
export type MaybeErrorResponse<D, E> = { result: D } | { error: E };
41+
42+
export function isErrorResponse<D, E>(
43+
res: MaybeErrorResponse<D, E>,
44+
): res is { error: E } {
45+
return "error" in res;
46+
}
47+
48+
export function isSuccessResponse<D, E>(
49+
res: MaybeErrorResponse<D, E>,
50+
): res is { result: D } {
51+
return "result" in res;
3852
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
export type { CreateClientConfig } from "../client/client.gen.js";
22
export * from "../client/index.js";
3-
export { configure, type EngineClientOptions } from "../configure.js";
3+
export {
4+
configure,
5+
type EngineClientOptions,
6+
isErrorResponse,
7+
isSuccessResponse,
8+
} from "../configure.js";

0 commit comments

Comments
 (0)