@nadohq/engine-client 0.14.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/EngineBaseClient-DOOXIhnZ.d.ts +75 -0
  2. package/dist/EngineBaseClient-DOOXIhnZ.d.ts.map +1 -0
  3. package/dist/EngineBaseClient-L1ue7jBx.d.cts +75 -0
  4. package/dist/EngineBaseClient-L1ue7jBx.d.cts.map +1 -0
  5. package/dist/EngineBaseClient-Uc1D8ftx.cjs +150 -0
  6. package/dist/EngineBaseClient-Uc1D8ftx.cjs.map +1 -0
  7. package/dist/EngineBaseClient.cjs +3 -167
  8. package/dist/EngineBaseClient.d.cts +2 -75
  9. package/dist/EngineBaseClient.d.ts +2 -75
  10. package/dist/EngineBaseClient.js +112 -131
  11. package/dist/EngineBaseClient.js.map +1 -1
  12. package/dist/EngineClient.cjs +13 -38
  13. package/dist/EngineClient.cjs.map +1 -1
  14. package/dist/EngineClient.d.cts +8 -18
  15. package/dist/EngineClient.d.cts.map +1 -0
  16. package/dist/EngineClient.d.ts +8 -18
  17. package/dist/EngineClient.d.ts.map +1 -0
  18. package/dist/EngineClient.js +9 -11
  19. package/dist/EngineClient.js.map +1 -1
  20. package/dist/EngineExecuteBuilder-VLrEndhv.d.cts +105 -0
  21. package/dist/EngineExecuteBuilder-VLrEndhv.d.cts.map +1 -0
  22. package/dist/EngineExecuteBuilder-t8EQ5Rmp.d.ts +105 -0
  23. package/dist/EngineExecuteBuilder-t8EQ5Rmp.d.ts.map +1 -0
  24. package/dist/EngineExecuteBuilder.cjs +232 -277
  25. package/dist/EngineExecuteBuilder.cjs.map +1 -1
  26. package/dist/EngineExecuteBuilder.d.cts +2 -108
  27. package/dist/EngineExecuteBuilder.d.ts +2 -108
  28. package/dist/EngineExecuteBuilder.js +230 -256
  29. package/dist/EngineExecuteBuilder.js.map +1 -1
  30. package/dist/EngineExecuteClient-0EBoXRd7.d.ts +24 -0
  31. package/dist/EngineExecuteClient-0EBoXRd7.d.ts.map +1 -0
  32. package/dist/EngineExecuteClient-BGlNK5Le.d.cts +24 -0
  33. package/dist/EngineExecuteClient-BGlNK5Le.d.cts.map +1 -0
  34. package/dist/EngineExecuteClient.cjs +57 -110
  35. package/dist/EngineExecuteClient.cjs.map +1 -1
  36. package/dist/EngineExecuteClient.d.cts +2 -28
  37. package/dist/EngineExecuteClient.d.ts +2 -28
  38. package/dist/EngineExecuteClient.js +54 -83
  39. package/dist/EngineExecuteClient.js.map +1 -1
  40. package/dist/EngineQueryClient-C_7p1oRx.d.cts +147 -0
  41. package/dist/EngineQueryClient-C_7p1oRx.d.cts.map +1 -0
  42. package/dist/EngineQueryClient-DQwCRaYl.d.ts +147 -0
  43. package/dist/EngineQueryClient-DQwCRaYl.d.ts.map +1 -0
  44. package/dist/EngineQueryClient.cjs +354 -447
  45. package/dist/EngineQueryClient.cjs.map +1 -1
  46. package/dist/EngineQueryClient.d.cts +2 -149
  47. package/dist/EngineQueryClient.d.ts +2 -149
  48. package/dist/EngineQueryClient.js +351 -440
  49. package/dist/EngineQueryClient.js.map +1 -1
  50. package/dist/EngineServerFailureError-CDabRrF4.d.ts +11 -0
  51. package/dist/EngineServerFailureError-CDabRrF4.d.ts.map +1 -0
  52. package/dist/EngineServerFailureError-DpPY0--L.d.cts +11 -0
  53. package/dist/EngineServerFailureError-DpPY0--L.d.cts.map +1 -0
  54. package/dist/EngineWebClient-CEwqgd4t.d.ts +35 -0
  55. package/dist/EngineWebClient-CEwqgd4t.d.ts.map +1 -0
  56. package/dist/EngineWebClient-DajZqKAQ.d.cts +35 -0
  57. package/dist/EngineWebClient-DajZqKAQ.d.cts.map +1 -0
  58. package/dist/EngineWebClient.cjs +49 -86
  59. package/dist/EngineWebClient.cjs.map +1 -1
  60. package/dist/EngineWebClient.d.cts +2 -39
  61. package/dist/EngineWebClient.d.ts +2 -39
  62. package/dist/EngineWebClient.js +47 -60
  63. package/dist/EngineWebClient.js.map +1 -1
  64. package/dist/clientExecuteTypes-BlJOgCL_.d.cts +91 -0
  65. package/dist/clientExecuteTypes-BlJOgCL_.d.cts.map +1 -0
  66. package/dist/clientExecuteTypes-CJ08_c4q.d.ts +91 -0
  67. package/dist/clientExecuteTypes-CJ08_c4q.d.ts.map +1 -0
  68. package/dist/clientQueryTypes-DlTtS_mX.d.cts +221 -0
  69. package/dist/clientQueryTypes-DlTtS_mX.d.cts.map +1 -0
  70. package/dist/clientQueryTypes-DuRgEeBT.d.ts +221 -0
  71. package/dist/clientQueryTypes-DuRgEeBT.d.ts.map +1 -0
  72. package/dist/endpoints.cjs +19 -45
  73. package/dist/endpoints.cjs.map +1 -1
  74. package/dist/endpoints.d.cts +4 -2
  75. package/dist/endpoints.d.cts.map +1 -0
  76. package/dist/endpoints.d.ts +4 -2
  77. package/dist/endpoints.d.ts.map +1 -0
  78. package/dist/endpoints.js +16 -18
  79. package/dist/endpoints.js.map +1 -1
  80. package/dist/index-CmCelmEL.d.cts +1 -0
  81. package/dist/index-D0E78WnU.d.ts +1 -0
  82. package/dist/index.cjs +26 -31
  83. package/dist/index.d.cts +12 -20
  84. package/dist/index.d.ts +12 -20
  85. package/dist/index.js +8 -6
  86. package/dist/queryDataMappers-BguxA579.d.ts +21 -0
  87. package/dist/queryDataMappers-BguxA579.d.ts.map +1 -0
  88. package/dist/queryDataMappers-DO9yWdLo.d.cts +21 -0
  89. package/dist/queryDataMappers-DO9yWdLo.d.cts.map +1 -0
  90. package/dist/serverExecuteTypes-CgbHjnWM.d.ts +92 -0
  91. package/dist/serverExecuteTypes-CgbHjnWM.d.ts.map +1 -0
  92. package/dist/serverExecuteTypes-DejTR8Is.d.cts +92 -0
  93. package/dist/serverExecuteTypes-DejTR8Is.d.cts.map +1 -0
  94. package/dist/serverQueryModelTypes-85xnbU-a.d.cts +98 -0
  95. package/dist/serverQueryModelTypes-85xnbU-a.d.cts.map +1 -0
  96. package/dist/serverQueryModelTypes-CENoy5Hm.d.ts +98 -0
  97. package/dist/serverQueryModelTypes-CENoy5Hm.d.ts.map +1 -0
  98. package/dist/serverQueryTypes-B3vC8vxT.d.ts +301 -0
  99. package/dist/serverQueryTypes-B3vC8vxT.d.ts.map +1 -0
  100. package/dist/serverQueryTypes-Dva9R2tV.d.cts +301 -0
  101. package/dist/serverQueryTypes-Dva9R2tV.d.cts.map +1 -0
  102. package/dist/serverSubscriptionEventTypes-BMUrTkTg.d.cts +135 -0
  103. package/dist/serverSubscriptionEventTypes-BMUrTkTg.d.cts.map +1 -0
  104. package/dist/serverSubscriptionEventTypes-UCYAjmt7.d.ts +135 -0
  105. package/dist/serverSubscriptionEventTypes-UCYAjmt7.d.ts.map +1 -0
  106. package/dist/serverSubscriptionTypes-BSuYa6z_.d.cts +82 -0
  107. package/dist/serverSubscriptionTypes-BSuYa6z_.d.cts.map +1 -0
  108. package/dist/serverSubscriptionTypes-DoMWeKgY.d.ts +82 -0
  109. package/dist/serverSubscriptionTypes-DoMWeKgY.d.ts.map +1 -0
  110. package/dist/types/EngineServerFailureError.cjs +9 -33
  111. package/dist/types/EngineServerFailureError.cjs.map +1 -1
  112. package/dist/types/EngineServerFailureError.d.cts +2 -11
  113. package/dist/types/EngineServerFailureError.d.ts +2 -11
  114. package/dist/types/EngineServerFailureError.js +8 -8
  115. package/dist/types/EngineServerFailureError.js.map +1 -1
  116. package/dist/types/clientExecuteTypes.cjs +0 -19
  117. package/dist/types/clientExecuteTypes.d.cts +2 -91
  118. package/dist/types/clientExecuteTypes.d.ts +2 -91
  119. package/dist/types/clientExecuteTypes.js +1 -1
  120. package/dist/types/clientQueryTypes.cjs +0 -19
  121. package/dist/types/clientQueryTypes.d.cts +2 -219
  122. package/dist/types/clientQueryTypes.d.ts +2 -219
  123. package/dist/types/clientQueryTypes.js +1 -1
  124. package/dist/types/index.cjs +5 -39
  125. package/dist/types/index.d.cts +9 -10
  126. package/dist/types/index.d.ts +9 -10
  127. package/dist/types/index.js +3 -10
  128. package/dist/types/serverExecuteTypes.cjs +0 -19
  129. package/dist/types/serverExecuteTypes.d.cts +2 -93
  130. package/dist/types/serverExecuteTypes.d.ts +2 -93
  131. package/dist/types/serverExecuteTypes.js +1 -1
  132. package/dist/types/serverQueryModelTypes.cjs +0 -19
  133. package/dist/types/serverQueryModelTypes.d.cts +2 -96
  134. package/dist/types/serverQueryModelTypes.d.ts +2 -96
  135. package/dist/types/serverQueryModelTypes.js +1 -1
  136. package/dist/types/serverQueryTypes.cjs +12 -36
  137. package/dist/types/serverQueryTypes.cjs.map +1 -1
  138. package/dist/types/serverQueryTypes.d.cts +2 -309
  139. package/dist/types/serverQueryTypes.d.ts +2 -309
  140. package/dist/types/serverQueryTypes.js +11 -11
  141. package/dist/types/serverQueryTypes.js.map +1 -1
  142. package/dist/types/serverSubscriptionEventTypes.cjs +0 -19
  143. package/dist/types/serverSubscriptionEventTypes.d.cts +2 -135
  144. package/dist/types/serverSubscriptionEventTypes.d.ts +2 -135
  145. package/dist/types/serverSubscriptionEventTypes.js +1 -1
  146. package/dist/types/serverSubscriptionTypes.cjs +0 -19
  147. package/dist/types/serverSubscriptionTypes.d.cts +2 -80
  148. package/dist/types/serverSubscriptionTypes.d.ts +2 -80
  149. package/dist/types/serverSubscriptionTypes.js +1 -1
  150. package/dist/utils/index.cjs +14 -25
  151. package/dist/utils/index.d.cts +2 -6
  152. package/dist/utils/index.d.ts +2 -6
  153. package/dist/utils/index.js +2 -3
  154. package/dist/utils/productEngineTypeMappers.cjs +16 -44
  155. package/dist/utils/productEngineTypeMappers.cjs.map +1 -1
  156. package/dist/utils/productEngineTypeMappers.d.cts +5 -3
  157. package/dist/utils/productEngineTypeMappers.d.cts.map +1 -0
  158. package/dist/utils/productEngineTypeMappers.d.ts +5 -3
  159. package/dist/utils/productEngineTypeMappers.d.ts.map +1 -0
  160. package/dist/utils/productEngineTypeMappers.js +12 -17
  161. package/dist/utils/productEngineTypeMappers.js.map +1 -1
  162. package/dist/utils/queryDataMappers.cjs +204 -292
  163. package/dist/utils/queryDataMappers.cjs.map +1 -1
  164. package/dist/utils/queryDataMappers.d.cts +2 -20
  165. package/dist/utils/queryDataMappers.d.ts +2 -20
  166. package/dist/utils/queryDataMappers.js +190 -264
  167. package/dist/utils/queryDataMappers.js.map +1 -1
  168. package/package.json +9 -9
  169. package/src/EngineQueryClient.ts +4 -0
  170. package/src/types/clientQueryTypes.ts +3 -0
  171. package/src/types/serverQueryTypes.ts +3 -0
  172. package/dist/EngineBaseClient.cjs.map +0 -1
  173. package/dist/index.cjs.map +0 -1
  174. package/dist/index.js.map +0 -1
  175. package/dist/types/clientExecuteTypes.cjs.map +0 -1
  176. package/dist/types/clientExecuteTypes.js.map +0 -1
  177. package/dist/types/clientQueryTypes.cjs.map +0 -1
  178. package/dist/types/clientQueryTypes.js.map +0 -1
  179. package/dist/types/index.cjs.map +0 -1
  180. package/dist/types/index.js.map +0 -1
  181. package/dist/types/serverExecuteTypes.cjs.map +0 -1
  182. package/dist/types/serverExecuteTypes.js.map +0 -1
  183. package/dist/types/serverQueryModelTypes.cjs.map +0 -1
  184. package/dist/types/serverQueryModelTypes.js.map +0 -1
  185. package/dist/types/serverSubscriptionEventTypes.cjs.map +0 -1
  186. package/dist/types/serverSubscriptionEventTypes.js.map +0 -1
  187. package/dist/types/serverSubscriptionTypes.cjs.map +0 -1
  188. package/dist/types/serverSubscriptionTypes.js.map +0 -1
  189. package/dist/utils/index.cjs.map +0 -1
  190. package/dist/utils/index.js.map +0 -1
@@ -0,0 +1,75 @@
1
+ import { G as EngineServerQueryResponseByType, H as EngineServerQueryRequestByType, U as EngineServerQueryRequestType, V as EngineServerQueryRequest } from "./serverQueryTypes-B3vC8vxT.js";
2
+ import { a as EngineServerExecuteRequestByType, l as EngineServerExecuteSuccessResult, o as EngineServerExecuteRequestType } from "./serverExecuteTypes-CgbHjnWM.js";
3
+ import { L as GetEngineNoncesParams, R as GetEngineNoncesResponse } from "./clientQueryTypes-DuRgEeBT.js";
4
+ import { SignableRequestType, SignableRequestTypeToParams, WalletClientWithAccount } from "@nadohq/shared";
5
+ import { AxiosInstance } from "axios";
6
+
7
+ //#region src/EngineBaseClient.d.ts
8
+ interface EngineClientOpts {
9
+ url: string;
10
+ walletClient?: WalletClientWithAccount;
11
+ linkedSignerWalletClient?: WalletClientWithAccount;
12
+ }
13
+ type EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;
14
+ /**
15
+ * Base client for all engine requests
16
+ */
17
+ declare class EngineBaseClient {
18
+ readonly opts: EngineClientOpts;
19
+ readonly axiosInstance: AxiosInstance;
20
+ constructor(opts: EngineClientOpts);
21
+ /**
22
+ * Sets the linked signer for execute requests
23
+ *
24
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
25
+ */
26
+ setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
27
+ getTxNonce(address?: string): Promise<string>;
28
+ getNonces(params: GetEngineNoncesParams): Promise<GetEngineNoncesResponse>;
29
+ /**
30
+ * Queries the engine, all query params are stringified into the query string
31
+ *
32
+ * @param requestType
33
+ * @param params
34
+ * @public
35
+ */
36
+ query<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): Promise<EngineServerQueryResponseByType[TRequestType]>;
37
+ /**
38
+ * A simple, typechecked fn for constructing a query request in the format expected by the server.
39
+ *
40
+ * @param requestType
41
+ * @param params
42
+ */
43
+ getQueryRequest<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): EngineServerQueryRequest<TRequestType>;
44
+ /**
45
+ * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
46
+ * in an EngineServerFailureError on failure.
47
+ *
48
+ * @param requestType
49
+ * @param params
50
+ * @public
51
+ */
52
+ execute<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): Promise<EngineServerExecuteSuccessResult<TRequestType>>;
53
+ /**
54
+ * A simple, typechecked fn for constructing an execute request in the format expected by the server.
55
+ *
56
+ * @param requestType
57
+ * @param params
58
+ */
59
+ getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): EngineExecuteRequestBody;
60
+ /**
61
+ * Signs a given request with the signer provided to the engine
62
+ *
63
+ * @param requestType
64
+ * @param verifyingContract
65
+ * @param chainId
66
+ * @param params
67
+ * @public
68
+ */
69
+ sign<T extends SignableRequestType>(requestType: T, verifyingContract: string, chainId: number, params: SignableRequestTypeToParams[T]): Promise<`0x${string}`>;
70
+ private checkResponseStatus;
71
+ private checkServerStatus;
72
+ }
73
+ //#endregion
74
+ export { EngineClientOpts as n, EngineBaseClient as t };
75
+ //# sourceMappingURL=EngineBaseClient-DOOXIhnZ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EngineBaseClient-DOOXIhnZ.d.ts","names":[],"sources":["../src/src/EngineBaseClient.ts"],"mappings":";;;;;;;UAwBiB,gBAAA;EAEf,GAAA;EAEA,YAAA,GAAe,uBAAA;EAEf,wBAAA,GAA2B,uBAAuB;AAAA;AAAA,KAI/C,wBAAA,GAA2B,OAAO,CAAC,gCAAA;;;;cAS3B,gBAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAjBS;;AAAuB;AACnD;;EA8BQ,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAKf,UAAA,CAAW,OAAA,YAAmB,OAAA;EAc9B,SAAA,CACX,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,uBAAA;EAxCA;;;;;;;EAwDE,KAAA,sBAA2B,4BAAA,CAAA,CACtC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,8BAAA,CAA+B,YAAA,IACtC,OAAA,CAAQ,+BAAA,CAAgC,YAAA;EApBjC;;;;;;EA4CH,eAAA,sBAAqC,4BAAA,CAAA,CAC1C,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,8BAAA,CAA+B,YAAA,IACtC,wBAAA,CAAyB,YAAA;EA3BjB;;;;;;;;EA0CE,OAAA,sBAA6B,8BAAA,CAAA,CACxC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,OAAA,CAAQ,gCAAA,CAAiC,YAAA;EAHF;;;;;;EAsBnC,iBAAA,sBAAuC,8BAAA,CAAA,CAC5C,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,wBAAA;EAH2C;;;;;;;;;EAkBjC,IAAA,WAAe,mBAAA,CAAA,CAC1B,WAAA,EAAa,CAAA,EACb,iBAAA,UACA,OAAA,UACA,MAAA,EAAQ,2BAAA,CAA4B,CAAA,IAAE,OAAA;EAAA,QAmBhC,mBAAA;EAAA,QAQA,iBAAA;AAAA"}
@@ -0,0 +1,75 @@
1
+ import { G as EngineServerQueryResponseByType, H as EngineServerQueryRequestByType, U as EngineServerQueryRequestType, V as EngineServerQueryRequest } from "./serverQueryTypes-Dva9R2tV.cjs";
2
+ import { a as EngineServerExecuteRequestByType, l as EngineServerExecuteSuccessResult, o as EngineServerExecuteRequestType } from "./serverExecuteTypes-DejTR8Is.cjs";
3
+ import { L as GetEngineNoncesParams, R as GetEngineNoncesResponse } from "./clientQueryTypes-DlTtS_mX.cjs";
4
+ import { SignableRequestType, SignableRequestTypeToParams, WalletClientWithAccount } from "@nadohq/shared";
5
+ import { AxiosInstance } from "axios";
6
+
7
+ //#region src/EngineBaseClient.d.ts
8
+ interface EngineClientOpts {
9
+ url: string;
10
+ walletClient?: WalletClientWithAccount;
11
+ linkedSignerWalletClient?: WalletClientWithAccount;
12
+ }
13
+ type EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;
14
+ /**
15
+ * Base client for all engine requests
16
+ */
17
+ declare class EngineBaseClient {
18
+ readonly opts: EngineClientOpts;
19
+ readonly axiosInstance: AxiosInstance;
20
+ constructor(opts: EngineClientOpts);
21
+ /**
22
+ * Sets the linked signer for execute requests
23
+ *
24
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
25
+ */
26
+ setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
27
+ getTxNonce(address?: string): Promise<string>;
28
+ getNonces(params: GetEngineNoncesParams): Promise<GetEngineNoncesResponse>;
29
+ /**
30
+ * Queries the engine, all query params are stringified into the query string
31
+ *
32
+ * @param requestType
33
+ * @param params
34
+ * @public
35
+ */
36
+ query<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): Promise<EngineServerQueryResponseByType[TRequestType]>;
37
+ /**
38
+ * A simple, typechecked fn for constructing a query request in the format expected by the server.
39
+ *
40
+ * @param requestType
41
+ * @param params
42
+ */
43
+ getQueryRequest<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): EngineServerQueryRequest<TRequestType>;
44
+ /**
45
+ * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
46
+ * in an EngineServerFailureError on failure.
47
+ *
48
+ * @param requestType
49
+ * @param params
50
+ * @public
51
+ */
52
+ execute<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): Promise<EngineServerExecuteSuccessResult<TRequestType>>;
53
+ /**
54
+ * A simple, typechecked fn for constructing an execute request in the format expected by the server.
55
+ *
56
+ * @param requestType
57
+ * @param params
58
+ */
59
+ getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): EngineExecuteRequestBody;
60
+ /**
61
+ * Signs a given request with the signer provided to the engine
62
+ *
63
+ * @param requestType
64
+ * @param verifyingContract
65
+ * @param chainId
66
+ * @param params
67
+ * @public
68
+ */
69
+ sign<T extends SignableRequestType>(requestType: T, verifyingContract: string, chainId: number, params: SignableRequestTypeToParams[T]): Promise<`0x${string}`>;
70
+ private checkResponseStatus;
71
+ private checkServerStatus;
72
+ }
73
+ //#endregion
74
+ export { EngineClientOpts as n, EngineBaseClient as t };
75
+ //# sourceMappingURL=EngineBaseClient-L1ue7jBx.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EngineBaseClient-L1ue7jBx.d.cts","names":[],"sources":["../src/src/EngineBaseClient.ts"],"mappings":";;;;;;;UAwBiB,gBAAA;EAEf,GAAA;EAEA,YAAA,GAAe,uBAAA;EAEf,wBAAA,GAA2B,uBAAuB;AAAA;AAAA,KAI/C,wBAAA,GAA2B,OAAO,CAAC,gCAAA;;;;cAS3B,gBAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAjBS;;AAAuB;AACnD;;EA8BQ,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAKf,UAAA,CAAW,OAAA,YAAmB,OAAA;EAc9B,SAAA,CACX,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,uBAAA;EAxCA;;;;;;;EAwDE,KAAA,sBAA2B,4BAAA,CAAA,CACtC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,8BAAA,CAA+B,YAAA,IACtC,OAAA,CAAQ,+BAAA,CAAgC,YAAA;EApBjC;;;;;;EA4CH,eAAA,sBAAqC,4BAAA,CAAA,CAC1C,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,8BAAA,CAA+B,YAAA,IACtC,wBAAA,CAAyB,YAAA;EA3BjB;;;;;;;;EA0CE,OAAA,sBAA6B,8BAAA,CAAA,CACxC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,OAAA,CAAQ,gCAAA,CAAiC,YAAA;EAHF;;;;;;EAsBnC,iBAAA,sBAAuC,8BAAA,CAAA,CAC5C,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,wBAAA;EAH2C;;;;;;;;;EAkBjC,IAAA,WAAe,mBAAA,CAAA,CAC1B,WAAA,EAAa,CAAA,EACb,iBAAA,UACA,OAAA,UACA,MAAA,EAAQ,2BAAA,CAA4B,CAAA,IAAE,OAAA;EAAA,QAmBhC,mBAAA;EAAA,QAQA,iBAAA;AAAA"}
@@ -0,0 +1,150 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ const require_types_EngineServerFailureError = require("./types/EngineServerFailureError.cjs");
24
+ let _nadohq_shared = require("@nadohq/shared");
25
+ let axios = require("axios");
26
+ axios = __toESM(axios, 1);
27
+ //#region src/EngineBaseClient.ts
28
+ /**
29
+ * Base client for all engine requests
30
+ */
31
+ var EngineBaseClient = class {
32
+ constructor(opts) {
33
+ this.opts = opts;
34
+ this.axiosInstance = axios.default.create({
35
+ withCredentials: true,
36
+ validateStatus: () => true
37
+ });
38
+ }
39
+ /**
40
+ * Sets the linked signer for execute requests
41
+ *
42
+ * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
43
+ */
44
+ setLinkedSigner(linkedSignerWalletClient) {
45
+ this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
46
+ }
47
+ async getTxNonce(address) {
48
+ const addr = address ?? this.opts.walletClient?.account.address;
49
+ if (!addr) throw new _nadohq_shared.WalletNotProvidedError();
50
+ return (await this.getNonces({ address: addr })).txNonce;
51
+ }
52
+ async getNonces(params) {
53
+ const baseResp = await this.query("nonces", params);
54
+ return {
55
+ orderNonce: baseResp.order_nonce,
56
+ txNonce: baseResp.tx_nonce
57
+ };
58
+ }
59
+ /**
60
+ * Queries the engine, all query params are stringified into the query string
61
+ *
62
+ * @param requestType
63
+ * @param params
64
+ * @public
65
+ */
66
+ async query(requestType, params) {
67
+ const request = this.getQueryRequest(requestType, params);
68
+ const response = await this.axiosInstance.post(`${this.opts.url}/query`, request);
69
+ this.checkResponseStatus(response);
70
+ this.checkServerStatus(response);
71
+ return response.data.data;
72
+ }
73
+ /**
74
+ * A simple, typechecked fn for constructing a query request in the format expected by the server.
75
+ *
76
+ * @param requestType
77
+ * @param params
78
+ */
79
+ getQueryRequest(requestType, params) {
80
+ return {
81
+ type: requestType,
82
+ ...params
83
+ };
84
+ }
85
+ /**
86
+ * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
87
+ * in an EngineServerFailureError on failure.
88
+ *
89
+ * @param requestType
90
+ * @param params
91
+ * @public
92
+ */
93
+ async execute(requestType, params) {
94
+ const reqBody = this.getExecuteRequest(requestType, params);
95
+ const response = await this.axiosInstance.post(`${this.opts.url}/execute`, reqBody);
96
+ this.checkResponseStatus(response);
97
+ this.checkServerStatus(response);
98
+ return response.data;
99
+ }
100
+ /**
101
+ * A simple, typechecked fn for constructing an execute request in the format expected by the server.
102
+ *
103
+ * @param requestType
104
+ * @param params
105
+ */
106
+ getExecuteRequest(requestType, params) {
107
+ return { [requestType]: params };
108
+ }
109
+ /**
110
+ * Signs a given request with the signer provided to the engine
111
+ *
112
+ * @param requestType
113
+ * @param verifyingContract
114
+ * @param chainId
115
+ * @param params
116
+ * @public
117
+ */
118
+ async sign(requestType, verifyingContract, chainId, params) {
119
+ const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
120
+ if (!walletClient) throw new _nadohq_shared.WalletNotProvidedError();
121
+ return (0, _nadohq_shared.getSignedTransactionRequest)({
122
+ chainId,
123
+ requestParams: params,
124
+ requestType,
125
+ walletClient,
126
+ verifyingContract
127
+ });
128
+ }
129
+ checkResponseStatus(response) {
130
+ if (response.status !== 200 || !response.data) throw Error(`Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`);
131
+ }
132
+ checkServerStatus(response) {
133
+ if (response.data.status !== "success") throw new require_types_EngineServerFailureError.EngineServerFailureError(response.data);
134
+ }
135
+ };
136
+ //#endregion
137
+ Object.defineProperty(exports, "EngineBaseClient", {
138
+ enumerable: true,
139
+ get: function() {
140
+ return EngineBaseClient;
141
+ }
142
+ });
143
+ Object.defineProperty(exports, "__toESM", {
144
+ enumerable: true,
145
+ get: function() {
146
+ return __toESM;
147
+ }
148
+ });
149
+
150
+ //# sourceMappingURL=EngineBaseClient-Uc1D8ftx.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EngineBaseClient-Uc1D8ftx.cjs","names":["WalletNotProvidedError","successResponse","EngineServerFailureError"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequest,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * A simple, typechecked fn for constructing a query request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): EngineServerQueryRequest<TRequestType> {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n EngineServerExecuteResult | EngineQueryRequestResponse\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;CAEA,MAAa,WAAW,SAAmC;EACzD,MAAM,OAAO,WAAW,KAAK,KAAK,cAAc,QAAQ;EAExD,IAAI,CAAC,MACH,MAAM,IAAIA,eAAAA,uBAAuB;EAGnC,QACE,MAAM,KAAK,UAAU,EACnB,SAAS,KACX,CAAC,GACD;CACJ;CAEA,MAAa,UACX,QACkC;EAClC,MAAM,WAAW,MAAM,KAAK,MAAM,UAAU,MAAM;EAElD,OAAO;GACL,YAAY,SAAS;GACrB,SAAS,SAAS;EACpB;CACF;;;;;;;;CASA,MAAa,MACX,aACA,QACwD;EACxD,MAAM,UAAU,KAAK,gBAAgB,aAAa,MAAM;EACxD,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,IAAI,SACjB,OACF;EAEA,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAO/B,OAAOC,SAAgB,KAAK;CAC9B;;;;;;;CAQA,gBACE,aACA,QACwC;EACxC,OAAO;GACL,MAAM;GACN,GAAG;EACL;CACF;;;;;;;;;CAUA,MAAa,QACX,aACA,QACyD;EACzD,MAAM,UAAU,KAAK,kBAAkB,aAAa,MAAM;EAC1D,MAAM,WAAW,MAAM,KAAK,cAAc,KAExC,GAAG,KAAK,KAAK,IAAI,WAAW,OAAO;EAErC,KAAK,oBAAoB,QAAQ;EACjC,KAAK,kBAAkB,QAAQ;EAG/B,OAAO,SAAS;CAClB;;;;;;;CAQA,kBACE,aACA,QAC0B;EAC1B,OAAO,GACJ,cAAc,OACjB;CACF;;;;;;;;;;CAWA,MAAa,KACX,aACA,mBACA,SACA,QACA;EAEA,MAAM,eACJ,KAAK,KAAK,4BAA4B,KAAK,KAAK;EAElD,IAAI,CAAC,cACH,MAAM,IAAID,eAAAA,uBAAuB;EAGnC,QAAA,GAAA,eAAA,6BAAmC;GACjC;GACA,eAAe;GACf;GACA;GACA;EACF,CAAC;CACH;CAEA,oBAA4B,UAAyB;EACnD,IAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,SAAS,MAChG;CAEJ;CAEA,kBACE,UAGA;EACA,IAAI,SAAS,KAAK,WAAW,WAC3B,MAAM,IAAIE,uCAAAA,yBAAyB,SAAS,IAAI;CAEpD;AACF"}
@@ -1,167 +1,3 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/EngineBaseClient.ts
31
- var EngineBaseClient_exports = {};
32
- __export(EngineBaseClient_exports, {
33
- EngineBaseClient: () => EngineBaseClient
34
- });
35
- module.exports = __toCommonJS(EngineBaseClient_exports);
36
- var import_shared = require("@nadohq/shared");
37
- var import_axios = __toESM(require("axios"), 1);
38
- var import_EngineServerFailureError = require("./types/EngineServerFailureError.cjs");
39
- var EngineBaseClient = class {
40
- constructor(opts) {
41
- this.opts = opts;
42
- this.axiosInstance = import_axios.default.create({
43
- withCredentials: true,
44
- // We have custom logic to validate response status and create an appropriate error
45
- validateStatus: () => true
46
- });
47
- }
48
- /**
49
- * Sets the linked signer for execute requests
50
- *
51
- * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
52
- */
53
- setLinkedSigner(linkedSignerWalletClient) {
54
- this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
55
- }
56
- async getTxNonce(address) {
57
- const addr = address ?? this.opts.walletClient?.account.address;
58
- if (!addr) {
59
- throw new import_shared.WalletNotProvidedError();
60
- }
61
- return (await this.getNonces({
62
- address: addr
63
- })).txNonce;
64
- }
65
- async getNonces(params) {
66
- const baseResp = await this.query("nonces", params);
67
- return {
68
- orderNonce: baseResp.order_nonce,
69
- txNonce: baseResp.tx_nonce
70
- };
71
- }
72
- /**
73
- * Queries the engine, all query params are stringified into the query string
74
- *
75
- * @param requestType
76
- * @param params
77
- * @public
78
- */
79
- async query(requestType, params) {
80
- const request = this.getQueryRequest(requestType, params);
81
- const response = await this.axiosInstance.post(
82
- `${this.opts.url}/query`,
83
- request
84
- );
85
- this.checkResponseStatus(response);
86
- this.checkServerStatus(response);
87
- const successResponse = response;
88
- return successResponse.data.data;
89
- }
90
- /**
91
- * A simple, typechecked fn for constructing a query request in the format expected by the server.
92
- *
93
- * @param requestType
94
- * @param params
95
- */
96
- getQueryRequest(requestType, params) {
97
- return {
98
- type: requestType,
99
- ...params
100
- };
101
- }
102
- /**
103
- * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
104
- * in an EngineServerFailureError on failure.
105
- *
106
- * @param requestType
107
- * @param params
108
- * @public
109
- */
110
- async execute(requestType, params) {
111
- const reqBody = this.getExecuteRequest(requestType, params);
112
- const response = await this.axiosInstance.post(`${this.opts.url}/execute`, reqBody);
113
- this.checkResponseStatus(response);
114
- this.checkServerStatus(response);
115
- return response.data;
116
- }
117
- /**
118
- * A simple, typechecked fn for constructing an execute request in the format expected by the server.
119
- *
120
- * @param requestType
121
- * @param params
122
- */
123
- getExecuteRequest(requestType, params) {
124
- return {
125
- [requestType]: params
126
- };
127
- }
128
- /**
129
- * Signs a given request with the signer provided to the engine
130
- *
131
- * @param requestType
132
- * @param verifyingContract
133
- * @param chainId
134
- * @param params
135
- * @public
136
- */
137
- async sign(requestType, verifyingContract, chainId, params) {
138
- const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
139
- if (!walletClient) {
140
- throw new import_shared.WalletNotProvidedError();
141
- }
142
- return (0, import_shared.getSignedTransactionRequest)({
143
- chainId,
144
- requestParams: params,
145
- requestType,
146
- walletClient,
147
- verifyingContract
148
- });
149
- }
150
- checkResponseStatus(response) {
151
- if (response.status !== 200 || !response.data) {
152
- throw Error(
153
- `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`
154
- );
155
- }
156
- }
157
- checkServerStatus(response) {
158
- if (response.data.status !== "success") {
159
- throw new import_EngineServerFailureError.EngineServerFailureError(response.data);
160
- }
161
- }
162
- };
163
- // Annotate the CommonJS export names for ESM import in node:
164
- 0 && (module.exports = {
165
- EngineBaseClient
166
- });
167
- //# sourceMappingURL=EngineBaseClient.cjs.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_EngineBaseClient = require("./EngineBaseClient-Uc1D8ftx.cjs");
3
+ exports.EngineBaseClient = require_EngineBaseClient.EngineBaseClient;
@@ -1,75 +1,2 @@
1
- import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/shared';
2
- import { AxiosInstance } from 'axios';
3
- import { EngineServerExecuteRequestType, EngineServerExecuteRequestByType, EngineServerExecuteSuccessResult } from './types/serverExecuteTypes.cjs';
4
- import { GetEngineNoncesParams, GetEngineNoncesResponse } from './types/clientQueryTypes.cjs';
5
- import { EngineServerQueryRequestType, EngineServerQueryRequestByType, EngineServerQueryResponseByType, EngineServerQueryRequest } from './types/serverQueryTypes.cjs';
6
- import 'bignumber.js';
7
- import './types/serverQueryModelTypes.cjs';
8
-
9
- interface EngineClientOpts {
10
- url: string;
11
- walletClient?: WalletClientWithAccount;
12
- linkedSignerWalletClient?: WalletClientWithAccount;
13
- }
14
- type EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;
15
- /**
16
- * Base client for all engine requests
17
- */
18
- declare class EngineBaseClient {
19
- readonly opts: EngineClientOpts;
20
- readonly axiosInstance: AxiosInstance;
21
- constructor(opts: EngineClientOpts);
22
- /**
23
- * Sets the linked signer for execute requests
24
- *
25
- * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
26
- */
27
- setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
28
- getTxNonce(address?: string): Promise<string>;
29
- getNonces(params: GetEngineNoncesParams): Promise<GetEngineNoncesResponse>;
30
- /**
31
- * Queries the engine, all query params are stringified into the query string
32
- *
33
- * @param requestType
34
- * @param params
35
- * @public
36
- */
37
- query<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): Promise<EngineServerQueryResponseByType[TRequestType]>;
38
- /**
39
- * A simple, typechecked fn for constructing a query request in the format expected by the server.
40
- *
41
- * @param requestType
42
- * @param params
43
- */
44
- getQueryRequest<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): EngineServerQueryRequest<TRequestType>;
45
- /**
46
- * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
47
- * in an EngineServerFailureError on failure.
48
- *
49
- * @param requestType
50
- * @param params
51
- * @public
52
- */
53
- execute<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): Promise<EngineServerExecuteSuccessResult<TRequestType>>;
54
- /**
55
- * A simple, typechecked fn for constructing an execute request in the format expected by the server.
56
- *
57
- * @param requestType
58
- * @param params
59
- */
60
- getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): EngineExecuteRequestBody;
61
- /**
62
- * Signs a given request with the signer provided to the engine
63
- *
64
- * @param requestType
65
- * @param verifyingContract
66
- * @param chainId
67
- * @param params
68
- * @public
69
- */
70
- sign<T extends SignableRequestType>(requestType: T, verifyingContract: string, chainId: number, params: SignableRequestTypeToParams[T]): Promise<`0x${string}`>;
71
- private checkResponseStatus;
72
- private checkServerStatus;
73
- }
74
-
75
- export { EngineBaseClient, type EngineClientOpts };
1
+ import { n as EngineClientOpts, t as EngineBaseClient } from "./EngineBaseClient-L1ue7jBx.cjs";
2
+ export { EngineBaseClient, EngineClientOpts };
@@ -1,75 +1,2 @@
1
- import { WalletClientWithAccount, SignableRequestType, SignableRequestTypeToParams } from '@nadohq/shared';
2
- import { AxiosInstance } from 'axios';
3
- import { EngineServerExecuteRequestType, EngineServerExecuteRequestByType, EngineServerExecuteSuccessResult } from './types/serverExecuteTypes.js';
4
- import { GetEngineNoncesParams, GetEngineNoncesResponse } from './types/clientQueryTypes.js';
5
- import { EngineServerQueryRequestType, EngineServerQueryRequestByType, EngineServerQueryResponseByType, EngineServerQueryRequest } from './types/serverQueryTypes.js';
6
- import 'bignumber.js';
7
- import './types/serverQueryModelTypes.js';
8
-
9
- interface EngineClientOpts {
10
- url: string;
11
- walletClient?: WalletClientWithAccount;
12
- linkedSignerWalletClient?: WalletClientWithAccount;
13
- }
14
- type EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;
15
- /**
16
- * Base client for all engine requests
17
- */
18
- declare class EngineBaseClient {
19
- readonly opts: EngineClientOpts;
20
- readonly axiosInstance: AxiosInstance;
21
- constructor(opts: EngineClientOpts);
22
- /**
23
- * Sets the linked signer for execute requests
24
- *
25
- * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer
26
- */
27
- setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
28
- getTxNonce(address?: string): Promise<string>;
29
- getNonces(params: GetEngineNoncesParams): Promise<GetEngineNoncesResponse>;
30
- /**
31
- * Queries the engine, all query params are stringified into the query string
32
- *
33
- * @param requestType
34
- * @param params
35
- * @public
36
- */
37
- query<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): Promise<EngineServerQueryResponseByType[TRequestType]>;
38
- /**
39
- * A simple, typechecked fn for constructing a query request in the format expected by the server.
40
- *
41
- * @param requestType
42
- * @param params
43
- */
44
- getQueryRequest<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): EngineServerQueryRequest<TRequestType>;
45
- /**
46
- * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
47
- * in an EngineServerFailureError on failure.
48
- *
49
- * @param requestType
50
- * @param params
51
- * @public
52
- */
53
- execute<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): Promise<EngineServerExecuteSuccessResult<TRequestType>>;
54
- /**
55
- * A simple, typechecked fn for constructing an execute request in the format expected by the server.
56
- *
57
- * @param requestType
58
- * @param params
59
- */
60
- getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): EngineExecuteRequestBody;
61
- /**
62
- * Signs a given request with the signer provided to the engine
63
- *
64
- * @param requestType
65
- * @param verifyingContract
66
- * @param chainId
67
- * @param params
68
- * @public
69
- */
70
- sign<T extends SignableRequestType>(requestType: T, verifyingContract: string, chainId: number, params: SignableRequestTypeToParams[T]): Promise<`0x${string}`>;
71
- private checkResponseStatus;
72
- private checkServerStatus;
73
- }
74
-
75
- export { EngineBaseClient, type EngineClientOpts };
1
+ import { n as EngineClientOpts, t as EngineBaseClient } from "./EngineBaseClient-DOOXIhnZ.js";
2
+ export { EngineBaseClient, EngineClientOpts };