@coinbase/cdp-sdk 1.1.1 → 1.2.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 (311) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/LICENSE +21 -0
  3. package/{dist → _cjs}/accounts/evm/toEvmServerAccount.js +1 -0
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -0
  5. package/{dist → _cjs}/accounts/evm/toEvmSmartAccount.js +1 -0
  6. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -0
  7. package/{dist → _cjs}/accounts/types.js +1 -0
  8. package/_cjs/accounts/types.js.map +1 -0
  9. package/{dist → _cjs}/actions/evm/sendUserOperation.js +1 -0
  10. package/_cjs/actions/evm/sendUserOperation.js.map +1 -0
  11. package/{dist → _cjs}/actions/evm/waitForUserOperation.js +10 -9
  12. package/_cjs/actions/evm/waitForUserOperation.js.map +1 -0
  13. package/{dist → _cjs}/analytics.js +7 -6
  14. package/_cjs/analytics.js.map +1 -0
  15. package/{dist → _cjs}/auth/errors.js +1 -0
  16. package/_cjs/auth/errors.js.map +1 -0
  17. package/{dist → _cjs}/auth/hooks/axios/index.js +2 -1
  18. package/_cjs/auth/hooks/axios/index.js.map +1 -0
  19. package/{dist → _cjs}/auth/hooks/axios/withAuth.js +3 -2
  20. package/_cjs/auth/hooks/axios/withAuth.js.map +1 -0
  21. package/{dist → _cjs}/auth/index.js +4 -3
  22. package/_cjs/auth/index.js.map +1 -0
  23. package/{dist → _cjs}/auth/utils/http.js +6 -5
  24. package/_cjs/auth/utils/http.js.map +1 -0
  25. package/{dist → _cjs}/auth/utils/index.js +3 -2
  26. package/_cjs/auth/utils/index.js.map +1 -0
  27. package/{dist → _cjs}/auth/utils/jwt.js +4 -3
  28. package/_cjs/auth/utils/jwt.js.map +1 -0
  29. package/{dist → _cjs}/client/cdp.js +13 -8
  30. package/_cjs/client/cdp.js.map +1 -0
  31. package/{dist → _cjs}/client/evm/evm.js +30 -28
  32. package/_cjs/client/evm/evm.js.map +1 -0
  33. package/{dist → _cjs}/client/evm/evm.types.js +1 -0
  34. package/_cjs/client/evm/evm.types.js.map +1 -0
  35. package/{dist → _cjs}/client/solana/index.js +3 -2
  36. package/_cjs/client/solana/index.js.map +1 -0
  37. package/{dist → _cjs}/client/solana/solana.js +9 -8
  38. package/_cjs/client/solana/solana.js.map +1 -0
  39. package/{dist → _cjs}/client/solana/solana.types.js +1 -0
  40. package/_cjs/client/solana/solana.types.js.map +1 -0
  41. package/{dist → _cjs}/constants.js +1 -0
  42. package/_cjs/constants.js.map +1 -0
  43. package/{dist → _cjs}/errors.js +1 -0
  44. package/_cjs/errors.js.map +1 -0
  45. package/{dist → _cjs}/index.js +4 -3
  46. package/_cjs/index.js.map +1 -0
  47. package/{dist → _cjs}/openapi-client/cdpApiClient.js +18 -14
  48. package/_cjs/openapi-client/cdpApiClient.js.map +1 -0
  49. package/{dist → _cjs}/openapi-client/errors.js +6 -0
  50. package/_cjs/openapi-client/errors.js.map +1 -0
  51. package/{dist → _cjs}/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +31 -30
  52. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -0
  53. package/{dist → _cjs}/openapi-client/generated/evm-accounts/evm-accounts.js +46 -41
  54. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -0
  55. package/{dist → _cjs}/openapi-client/generated/evm-accounts/evm-accounts.msw.js +73 -40
  56. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -0
  57. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +69 -0
  58. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -0
  59. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +188 -0
  60. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -0
  61. package/{dist → _cjs}/openapi-client/generated/faucets/faucets.js +18 -13
  62. package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -0
  63. package/{dist → _cjs}/openapi-client/generated/faucets/faucets.msw.js +16 -12
  64. package/_cjs/openapi-client/generated/faucets/faucets.msw.js.map +1 -0
  65. package/{dist → _cjs}/openapi-client/generated/index.msw.js +5 -4
  66. package/_cjs/openapi-client/generated/index.msw.js.map +1 -0
  67. package/{dist → _cjs}/openapi-client/generated/solana-accounts/solana-accounts.js +38 -35
  68. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -0
  69. package/{dist → _cjs}/openapi-client/generated/solana-accounts/solana-accounts.msw.js +68 -35
  70. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -0
  71. package/{dist → _cjs}/openapi-client/index.js +12 -11
  72. package/_cjs/openapi-client/index.js.map +1 -0
  73. package/_cjs/package.json +1 -0
  74. package/{dist → _cjs}/types/calls.js +1 -0
  75. package/_cjs/types/calls.js.map +1 -0
  76. package/{dist → _cjs}/types/contract.js +1 -0
  77. package/_cjs/types/contract.js.map +1 -0
  78. package/{dist → _cjs}/types/misc.js +1 -0
  79. package/_cjs/types/misc.js.map +1 -0
  80. package/{dist → _cjs}/types/multicall.js +1 -0
  81. package/_cjs/types/multicall.js.map +1 -0
  82. package/{dist → _cjs}/types/utils.js +1 -0
  83. package/_cjs/types/utils.js.map +1 -0
  84. package/{dist → _cjs}/utils/wait.js +3 -2
  85. package/_cjs/utils/wait.js.map +1 -0
  86. package/_cjs/version.js +5 -0
  87. package/_cjs/version.js.map +1 -0
  88. package/_esm/accounts/evm/toEvmServerAccount.js +40 -0
  89. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -0
  90. package/_esm/accounts/evm/toEvmSmartAccount.js +22 -0
  91. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -0
  92. package/_esm/accounts/types.js +2 -0
  93. package/_esm/accounts/types.js.map +1 -0
  94. package/_esm/actions/evm/sendUserOperation.js +85 -0
  95. package/_esm/actions/evm/sendUserOperation.js.map +1 -0
  96. package/_esm/actions/evm/waitForUserOperation.js +58 -0
  97. package/_esm/actions/evm/waitForUserOperation.js.map +1 -0
  98. package/_esm/analytics.js +84 -0
  99. package/_esm/analytics.js.map +1 -0
  100. package/_esm/auth/errors.js +57 -0
  101. package/_esm/auth/errors.js.map +1 -0
  102. package/_esm/auth/hooks/axios/index.js +2 -0
  103. package/_esm/auth/hooks/axios/index.js.map +1 -0
  104. package/_esm/auth/hooks/axios/withAuth.js +71 -0
  105. package/_esm/auth/hooks/axios/withAuth.js.map +1 -0
  106. package/_esm/auth/index.js +5 -0
  107. package/_esm/auth/index.js.map +1 -0
  108. package/_esm/auth/utils/http.js +70 -0
  109. package/_esm/auth/utils/http.js.map +1 -0
  110. package/_esm/auth/utils/index.js +3 -0
  111. package/_esm/auth/utils/index.js.map +1 -0
  112. package/_esm/auth/utils/jwt.js +199 -0
  113. package/_esm/auth/utils/jwt.js.map +1 -0
  114. package/_esm/client/cdp.js +95 -0
  115. package/_esm/client/cdp.js.map +1 -0
  116. package/_esm/client/evm/evm.js +518 -0
  117. package/_esm/client/evm/evm.js.map +1 -0
  118. package/_esm/client/evm/evm.types.js +2 -0
  119. package/_esm/client/evm/evm.types.js.map +1 -0
  120. package/_esm/client/solana/index.js +2 -0
  121. package/_esm/client/solana/index.js.map +1 -0
  122. package/_esm/client/solana/solana.js +204 -0
  123. package/_esm/client/solana/solana.js.map +1 -0
  124. package/_esm/client/solana/solana.types.js +2 -0
  125. package/_esm/client/solana/solana.types.js.map +1 -0
  126. package/_esm/constants.js +5 -0
  127. package/_esm/constants.js.map +1 -0
  128. package/_esm/errors.js +18 -0
  129. package/_esm/errors.js.map +1 -0
  130. package/_esm/index.js +3 -0
  131. package/_esm/index.js.map +1 -0
  132. package/_esm/openapi-client/cdpApiClient.js +112 -0
  133. package/_esm/openapi-client/cdpApiClient.js.map +1 -0
  134. package/_esm/openapi-client/errors.js +71 -0
  135. package/_esm/openapi-client/errors.js.map +1 -0
  136. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +52 -0
  137. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -0
  138. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +80 -0
  139. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -0
  140. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +128 -0
  141. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -0
  142. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +60 -0
  143. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -0
  144. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +172 -0
  145. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -0
  146. package/_esm/openapi-client/generated/faucets/faucets.js +51 -0
  147. package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -0
  148. package/_esm/openapi-client/generated/faucets/faucets.msw.js +39 -0
  149. package/_esm/openapi-client/generated/faucets/faucets.msw.js.map +1 -0
  150. package/_esm/openapi-client/generated/index.msw.js +5 -0
  151. package/_esm/openapi-client/generated/index.msw.js.map +1 -0
  152. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +73 -0
  153. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -0
  154. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +116 -0
  155. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -0
  156. package/_esm/openapi-client/index.js +27 -0
  157. package/_esm/openapi-client/index.js.map +1 -0
  158. package/_esm/package.json +1 -0
  159. package/_esm/types/calls.js +4 -0
  160. package/_esm/types/calls.js.map +1 -0
  161. package/_esm/types/contract.js +4 -0
  162. package/_esm/types/contract.js.map +1 -0
  163. package/_esm/types/misc.js +3 -0
  164. package/_esm/types/misc.js.map +1 -0
  165. package/_esm/types/multicall.js +2 -0
  166. package/_esm/types/multicall.js.map +1 -0
  167. package/_esm/types/utils.js +4 -0
  168. package/_esm/types/utils.js.map +1 -0
  169. package/_esm/utils/wait.js +32 -0
  170. package/_esm/utils/wait.js.map +1 -0
  171. package/_esm/version.js +2 -0
  172. package/_esm/version.js.map +1 -0
  173. package/{dist → _types}/accounts/evm/toEvmServerAccount.d.ts +3 -2
  174. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -0
  175. package/{dist → _types}/accounts/evm/toEvmSmartAccount.d.ts +3 -2
  176. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -0
  177. package/{dist → _types}/accounts/types.d.ts +3 -2
  178. package/_types/accounts/types.d.ts.map +1 -0
  179. package/{dist → _types}/actions/evm/sendUserOperation.d.ts +5 -5
  180. package/_types/actions/evm/sendUserOperation.d.ts.map +1 -0
  181. package/{dist → _types}/actions/evm/waitForUserOperation.d.ts +4 -3
  182. package/_types/actions/evm/waitForUserOperation.d.ts.map +1 -0
  183. package/{dist → _types}/analytics.d.ts +1 -0
  184. package/_types/analytics.d.ts.map +1 -0
  185. package/{dist → _types}/auth/errors.d.ts +1 -0
  186. package/_types/auth/errors.d.ts.map +1 -0
  187. package/_types/auth/hooks/axios/index.d.ts +2 -0
  188. package/_types/auth/hooks/axios/index.d.ts.map +1 -0
  189. package/{dist → _types}/auth/hooks/axios/withAuth.d.ts +1 -0
  190. package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -0
  191. package/_types/auth/index.d.ts +5 -0
  192. package/_types/auth/index.d.ts.map +1 -0
  193. package/{dist → _types}/auth/utils/http.d.ts +1 -0
  194. package/_types/auth/utils/http.d.ts.map +1 -0
  195. package/_types/auth/utils/index.d.ts +3 -0
  196. package/_types/auth/utils/index.d.ts.map +1 -0
  197. package/{dist → _types}/auth/utils/jwt.d.ts +1 -0
  198. package/_types/auth/utils/jwt.d.ts.map +1 -0
  199. package/{dist → _types}/client/cdp.d.ts +3 -2
  200. package/_types/client/cdp.d.ts.map +1 -0
  201. package/{dist → _types}/client/evm/evm.d.ts +4 -3
  202. package/_types/client/evm/evm.d.ts.map +1 -0
  203. package/{dist → _types}/client/evm/evm.types.d.ts +7 -6
  204. package/_types/client/evm/evm.types.d.ts.map +1 -0
  205. package/_types/client/solana/index.d.ts +2 -0
  206. package/_types/client/solana/index.d.ts.map +1 -0
  207. package/{dist → _types}/client/solana/solana.d.ts +2 -1
  208. package/_types/client/solana/solana.d.ts.map +1 -0
  209. package/{dist → _types}/client/solana/solana.types.d.ts +2 -1
  210. package/_types/client/solana/solana.types.d.ts.map +1 -0
  211. package/{dist → _types}/constants.d.ts +1 -0
  212. package/_types/constants.d.ts.map +1 -0
  213. package/{dist → _types}/errors.d.ts +1 -0
  214. package/_types/errors.d.ts.map +1 -0
  215. package/_types/index.d.ts +4 -0
  216. package/_types/index.d.ts.map +1 -0
  217. package/{dist → _types}/openapi-client/cdpApiClient.d.ts +1 -0
  218. package/_types/openapi-client/cdpApiClient.d.ts.map +1 -0
  219. package/{dist → _types}/openapi-client/errors.d.ts +2 -1
  220. package/_types/openapi-client/errors.d.ts.map +1 -0
  221. package/{dist → _types}/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +13 -12
  222. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -0
  223. package/{dist → _types}/openapi-client/generated/evm-accounts/evm-accounts.d.ts +24 -23
  224. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -0
  225. package/{dist → _types}/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +3 -2
  226. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -0
  227. package/{dist → _types}/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +21 -20
  228. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -0
  229. package/{dist → _types}/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +3 -2
  230. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -0
  231. package/{dist → _types}/openapi-client/generated/faucets/faucets.d.ts +9 -8
  232. package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -0
  233. package/{dist → _types}/openapi-client/generated/faucets/faucets.msw.d.ts +3 -2
  234. package/_types/openapi-client/generated/faucets/faucets.msw.d.ts.map +1 -0
  235. package/_types/openapi-client/generated/index.msw.d.ts +5 -0
  236. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -0
  237. package/{dist → _types}/openapi-client/generated/solana-accounts/solana-accounts.d.ts +21 -20
  238. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -0
  239. package/{dist → _types}/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +3 -2
  240. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -0
  241. package/_types/openapi-client/index.d.ts +56 -0
  242. package/_types/openapi-client/index.d.ts.map +1 -0
  243. package/{dist → _types}/types/calls.d.ts +4 -3
  244. package/_types/types/calls.d.ts.map +1 -0
  245. package/{dist → _types}/types/contract.d.ts +3 -2
  246. package/_types/types/contract.d.ts.map +1 -0
  247. package/{dist → _types}/types/misc.d.ts +1 -0
  248. package/_types/types/misc.d.ts.map +1 -0
  249. package/{dist → _types}/types/multicall.d.ts +2 -1
  250. package/_types/types/multicall.d.ts.map +1 -0
  251. package/{dist → _types}/types/utils.d.ts +1 -0
  252. package/_types/types/utils.d.ts.map +1 -0
  253. package/{dist → _types}/utils/wait.d.ts +1 -0
  254. package/_types/utils/wait.d.ts.map +1 -0
  255. package/_types/version.d.ts +2 -0
  256. package/_types/version.d.ts.map +1 -0
  257. package/accounts/evm/toEvmServerAccount.ts +60 -0
  258. package/accounts/evm/toEvmSmartAccount.ts +37 -0
  259. package/accounts/types.ts +53 -0
  260. package/actions/evm/sendUserOperation.ts +163 -0
  261. package/actions/evm/waitForUserOperation.ts +115 -0
  262. package/analytics.ts +123 -0
  263. package/auth/README.md +145 -0
  264. package/auth/errors.ts +59 -0
  265. package/auth/hooks/axios/index.ts +1 -0
  266. package/auth/hooks/axios/withAuth.ts +120 -0
  267. package/auth/index.ts +5 -0
  268. package/auth/utils/http.ts +146 -0
  269. package/auth/utils/index.ts +2 -0
  270. package/auth/utils/jwt.ts +324 -0
  271. package/client/cdp.ts +113 -0
  272. package/client/evm/evm.ts +606 -0
  273. package/client/evm/evm.types.ts +303 -0
  274. package/client/solana/index.ts +1 -0
  275. package/client/solana/solana.ts +237 -0
  276. package/client/solana/solana.types.ts +114 -0
  277. package/constants.ts +4 -0
  278. package/errors.ts +17 -0
  279. package/index.ts +4 -0
  280. package/openapi-client/cdpApiClient.ts +214 -0
  281. package/openapi-client/errors.ts +96 -0
  282. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +411 -0
  283. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +242 -0
  284. package/openapi-client/generated/evm-accounts/evm-accounts.ts +150 -0
  285. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +283 -0
  286. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +131 -0
  287. package/openapi-client/generated/faucets/faucets.msw.ts +76 -0
  288. package/openapi-client/generated/faucets/faucets.ts +83 -0
  289. package/openapi-client/generated/index.msw.ts +4 -0
  290. package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +219 -0
  291. package/openapi-client/generated/solana-accounts/solana-accounts.ts +143 -0
  292. package/openapi-client/index.ts +32 -0
  293. package/package.json +31 -66
  294. package/types/calls.ts +40 -0
  295. package/types/contract.ts +126 -0
  296. package/types/misc.ts +5 -0
  297. package/types/multicall.ts +29 -0
  298. package/types/utils.ts +288 -0
  299. package/utils/wait.ts +52 -0
  300. package/version.ts +1 -0
  301. package/dist/auth/hooks/axios/index.d.ts +0 -1
  302. package/dist/auth/index.d.ts +0 -4
  303. package/dist/auth/utils/index.d.ts +0 -2
  304. package/dist/client/evm/index.d.ts +0 -1
  305. package/dist/client/evm/index.js +0 -5
  306. package/dist/client/solana/index.d.ts +0 -1
  307. package/dist/index.d.ts +0 -3
  308. package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +0 -66
  309. package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +0 -99
  310. package/dist/openapi-client/generated/index.msw.d.ts +0 -4
  311. package/dist/openapi-client/index.d.ts +0 -55
@@ -0,0 +1,126 @@
1
+ /* eslint-disable */
2
+ // Adapted from viem (https://github.com/wevm/viem)
3
+
4
+ import type {
5
+ Abi,
6
+ AbiFunction,
7
+ AbiParametersToPrimitiveTypes,
8
+ AbiStateMutability,
9
+ Address,
10
+ ExtractAbiFunction,
11
+ ExtractAbiFunctionNames,
12
+ ResolvedRegister,
13
+ } from "abitype";
14
+
15
+ import type { Hex } from "./misc.js";
16
+ import type { IsUnion, UnionToTuple } from "./utils.js";
17
+
18
+ export type ContractFunctionName<
19
+ abi extends Abi | readonly unknown[] = Abi,
20
+ mutability extends AbiStateMutability = AbiStateMutability,
21
+ > =
22
+ ExtractAbiFunctionNames<
23
+ abi extends Abi ? abi : Abi,
24
+ mutability
25
+ > extends infer functionName extends string
26
+ ? [functionName] extends [never]
27
+ ? string
28
+ : functionName
29
+ : string;
30
+
31
+ export type ContractFunctionArgs<
32
+ abi extends Abi | readonly unknown[] = Abi,
33
+ mutability extends AbiStateMutability = AbiStateMutability,
34
+ functionName extends ContractFunctionName<abi, mutability> = ContractFunctionName<
35
+ abi,
36
+ mutability
37
+ >,
38
+ > =
39
+ AbiParametersToPrimitiveTypes<
40
+ ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName, mutability>["inputs"],
41
+ "inputs"
42
+ > extends infer args
43
+ ? [args] extends [never]
44
+ ? readonly unknown[]
45
+ : args
46
+ : readonly unknown[];
47
+
48
+ export type Widen<type> =
49
+ | ([unknown] extends [type] ? unknown : never)
50
+ | (type extends Function ? type : never)
51
+ | (type extends ResolvedRegister["BigIntType"] ? bigint : never)
52
+ | (type extends boolean ? boolean : never)
53
+ | (type extends ResolvedRegister["IntType"] ? number : never)
54
+ | (type extends string
55
+ ? type extends ResolvedRegister["AddressType"]
56
+ ? ResolvedRegister["AddressType"]
57
+ : type extends ResolvedRegister["BytesType"]["inputs"]
58
+ ? ResolvedRegister["BytesType"]
59
+ : string
60
+ : never)
61
+ | (type extends readonly [] ? readonly [] : never)
62
+ | (type extends Record<string, unknown> ? { [K in keyof type]: Widen<type[K]> } : never)
63
+ | (type extends { length: number }
64
+ ? {
65
+ [K in keyof type]: Widen<type[K]>;
66
+ } extends infer Val extends readonly unknown[]
67
+ ? readonly [...Val]
68
+ : never
69
+ : never);
70
+
71
+ export type UnionWiden<type> = type extends any ? Widen<type> : never;
72
+
73
+ export type ExtractAbiFunctionForArgs<
74
+ abi extends Abi,
75
+ mutability extends AbiStateMutability,
76
+ functionName extends ContractFunctionName<abi, mutability>,
77
+ args extends ContractFunctionArgs<abi, mutability, functionName>,
78
+ > =
79
+ ExtractAbiFunction<abi, functionName, mutability> extends infer abiFunction extends AbiFunction
80
+ ? IsUnion<abiFunction> extends true // narrow overloads using `args` by converting to tuple and filtering out overloads that don't match
81
+ ? UnionToTuple<abiFunction> extends infer abiFunctions extends readonly AbiFunction[]
82
+ ? // convert back to union (removes `never` tuple entries)
83
+ { [k in keyof abiFunctions]: CheckArgs<abiFunctions[k], args> }[number]
84
+ : never
85
+ : abiFunction
86
+ : never;
87
+ type CheckArgs<
88
+ abiFunction extends AbiFunction,
89
+ args,
90
+ ///
91
+ targetArgs extends AbiParametersToPrimitiveTypes<
92
+ abiFunction["inputs"],
93
+ "inputs"
94
+ > = AbiParametersToPrimitiveTypes<abiFunction["inputs"], "inputs">,
95
+ > = (readonly [] extends args ? readonly [] : args) extends targetArgs // fallback to `readonly []` if `args` has no value (e.g. `args` property not provided)
96
+ ? abiFunction
97
+ : never;
98
+
99
+ export type ContractFunctionParameters<
100
+ abi extends Abi | readonly unknown[] = Abi,
101
+ mutability extends AbiStateMutability = AbiStateMutability,
102
+ functionName extends ContractFunctionName<abi, mutability> = ContractFunctionName<
103
+ abi,
104
+ mutability
105
+ >,
106
+ args extends ContractFunctionArgs<abi, mutability, functionName> = ContractFunctionArgs<
107
+ abi,
108
+ mutability,
109
+ functionName
110
+ >,
111
+ deployless extends boolean = false,
112
+ ///
113
+ allFunctionNames = ContractFunctionName<abi, mutability>,
114
+ allArgs = ContractFunctionArgs<abi, mutability, functionName>,
115
+ /*
116
+ * when `args` is inferred to `readonly []` ("inputs": []) or `never` (`abi` declared as `Abi` or not inferrable), allow `args` to be optional.
117
+ * important that both branches return same structural type
118
+ */
119
+ > = {
120
+ abi: abi;
121
+ functionName:
122
+ | allFunctionNames // show all options
123
+ | (functionName extends allFunctionNames ? functionName : never); // infer value
124
+ args?: (abi extends Abi ? UnionWiden<args> : never) | allArgs | undefined;
125
+ } & (readonly [] extends allArgs ? {} : { args: Widen<args> }) &
126
+ (deployless extends true ? { address?: undefined; code: Hex } : { address: Address });
package/types/misc.ts ADDED
@@ -0,0 +1,5 @@
1
+ // Adapted from viem (https://github.com/wevm/viem)
2
+
3
+ export type Hex = `0x${string}`;
4
+ export type Hash = `0x${string}`;
5
+ export type Address = `0x${string}`;
@@ -0,0 +1,29 @@
1
+ // Adapted from viem (https://github.com/wevm/viem)
2
+ import type {
3
+ ContractFunctionArgs,
4
+ ContractFunctionName,
5
+ ContractFunctionParameters,
6
+ } from "./contract.js";
7
+ import type { Abi, AbiStateMutability } from "abitype";
8
+
9
+ // infer contract parameters from `unknown`
10
+ export type GetMulticallContractParameters<
11
+ contract,
12
+ mutability extends AbiStateMutability,
13
+ > = contract extends { abi: infer abi extends Abi } // 1. Check if `abi` is const-asserted or defined inline
14
+ ? // 1a. Check if `functionName` is valid for `abi`
15
+ contract extends {
16
+ functionName: infer functionName extends ContractFunctionName<abi, mutability>;
17
+ }
18
+ ? // 1aa. Check if `args` is valid for `abi` and `functionName`
19
+ contract extends {
20
+ args: infer args extends ContractFunctionArgs<abi, mutability, functionName>;
21
+ }
22
+ ? ContractFunctionParameters<abi, mutability, functionName, args> // `args` valid, pass through
23
+ : ContractFunctionParameters<abi, mutability, functionName> // invalid `args`
24
+ : // 1b. `functionName` is invalid, check if `abi` is declared as `Abi`
25
+ Abi extends abi
26
+ ? ContractFunctionParameters // `abi` declared as `Abi`, unable to infer types further
27
+ : // `abi` is const-asserted or defined inline, infer types for `functionName` and `args`
28
+ ContractFunctionParameters<abi, mutability>
29
+ : ContractFunctionParameters<readonly unknown[]>; // invalid `contract['abi']`, set to `readonly unknown[]`
package/types/utils.ts ADDED
@@ -0,0 +1,288 @@
1
+ /* eslint-disable */
2
+ // Adapted from viem (https://github.com/wevm/viem)
3
+
4
+ /**
5
+ * Filters out all members of {@link T} that are not {@link P}
6
+ *
7
+ * @param T - Items to filter
8
+ * @param P - Type to filter out
9
+ * @returns Filtered items
10
+ *
11
+ * @example
12
+ * type Result = Filter<['a', 'b', 'c'], 'b'>
13
+ * // ^? type Result = ['a', 'c']
14
+ */
15
+ export type Filter<
16
+ T extends readonly unknown[],
17
+ P,
18
+ Acc extends readonly unknown[] = [],
19
+ > = T extends readonly [infer F, ...infer Rest extends readonly unknown[]]
20
+ ? [F] extends [P]
21
+ ? Filter<Rest, P, [...Acc, F]>
22
+ : Filter<Rest, P, Acc>
23
+ : readonly [...Acc];
24
+
25
+ /**
26
+ * @description Checks if {@link T} can be narrowed further than {@link U}
27
+ * @param T - Type to check
28
+ * @param U - Type to against
29
+ * @example
30
+ * type Result = IsNarrowable<'foo', string>
31
+ * // ^? true
32
+ */
33
+ export type IsNarrowable<T, U> =
34
+ IsNever<(T extends U ? true : false) & (U extends T ? false : true)> extends true ? false : true;
35
+
36
+ /**
37
+ * @description Checks if {@link T} is `never`
38
+ * @param T - Type to check
39
+ * @example
40
+ * type Result = IsNever<never>
41
+ * // ^? type Result = true
42
+ */
43
+ export type IsNever<T> = [T] extends [never] ? true : false;
44
+
45
+ /** Removes `readonly` from all properties of an object. */
46
+ export type Mutable<type extends object> = {
47
+ -readonly [key in keyof type]: type[key];
48
+ };
49
+
50
+ /**
51
+ * @description Evaluates boolean "or" condition for {@link T} properties.
52
+ * @param T - Type to check
53
+ *
54
+ * @example
55
+ * type Result = Or<[false, true, false]>
56
+ * // ^? type Result = true
57
+ *
58
+ * @example
59
+ * type Result = Or<[false, false, false]>
60
+ * // ^? type Result = false
61
+ */
62
+ export type Or<T extends readonly unknown[]> = T extends readonly [infer Head, ...infer Tail]
63
+ ? Head extends true
64
+ ? true
65
+ : Or<Tail>
66
+ : false;
67
+
68
+ /**
69
+ * @description Checks if {@link T} is `undefined`
70
+ * @param T - Type to check
71
+ * @example
72
+ * type Result = IsUndefined<undefined>
73
+ * // ^? type Result = true
74
+ */
75
+ export type IsUndefined<T> = [undefined] extends [T] ? true : false;
76
+
77
+ export type MaybePromise<T> = T | Promise<T>;
78
+
79
+ /**
80
+ * @description Makes attributes on the type T required if required is true.
81
+ *
82
+ * @example
83
+ * MaybeRequired<{ a: string, b?: number }, true>
84
+ * => { a: string, b: number }
85
+ *
86
+ * MaybeRequired<{ a: string, b?: number }, false>
87
+ * => { a: string, b?: number }
88
+ */
89
+ export type MaybeRequired<T, required extends boolean> = required extends true
90
+ ? ExactRequired<T>
91
+ : T;
92
+
93
+ /**
94
+ * @description Assigns the properties of U onto T.
95
+ *
96
+ * @example
97
+ * Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
98
+ * => { a: undefined, b: number, c: boolean }
99
+ */
100
+ export type Assign<T, U> = Assign_<T, U> & U;
101
+ type Assign_<T, U> = {
102
+ [K in keyof T as K extends keyof U ? (U[K] extends void ? never : K) : K]: K extends keyof U
103
+ ? U[K]
104
+ : T[K];
105
+ };
106
+
107
+ // TODO: Remove when peer dep `typescript@>=4.5` (NoInfer is native)
108
+ export type NoInfer<type> = [type][type extends any ? 0 : never];
109
+
110
+ /**
111
+ * @description Constructs a type by excluding `undefined` from `T`.
112
+ *
113
+ * @example
114
+ * NoUndefined<string | undefined>
115
+ * => string
116
+ *
117
+ * @internal
118
+ */
119
+ export type NoUndefined<T> = T extends undefined ? never : T;
120
+
121
+ /** Strict version of built-in Omit type */
122
+ export type Omit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
123
+
124
+ /**
125
+ * @description Creates a type that is a partial of T, but with the required keys K.
126
+ *
127
+ * @example
128
+ * PartialBy<{ a: string, b: number }, 'a'>
129
+ * => { a?: string, b: number }
130
+ */
131
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & ExactPartial<Pick<T, K>>;
132
+
133
+ /**
134
+ * @description Combines members of an intersection into a readable type.
135
+ *
136
+ * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
137
+ * @example
138
+ * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
139
+ * => { a: string, b: string, c: number, d: bigint }
140
+ */
141
+ export type Prettify<T> = {
142
+ [K in keyof T]: T[K];
143
+ } & {};
144
+
145
+ /** @internal */
146
+ export type Evaluate<type> = {
147
+ [key in keyof type]: type[key];
148
+ } & {};
149
+
150
+ /**
151
+ * @description Creates a type that is T with the required keys K.
152
+ *
153
+ * @example
154
+ * RequiredBy<{ a?: string, b: number }, 'a'>
155
+ * => { a: string, b: number }
156
+ */
157
+ export type RequiredBy<T, K extends keyof T> = Omit<T, K> & ExactRequired<Pick<T, K>>;
158
+
159
+ /**
160
+ * @description Returns truthy if `array` contains `value`.
161
+ *
162
+ * @example
163
+ * Some<[1, 2, 3], 2>
164
+ * => true
165
+ */
166
+ export type Some<array extends readonly unknown[], value> = array extends readonly [
167
+ value,
168
+ ...unknown[],
169
+ ]
170
+ ? true
171
+ : array extends readonly [unknown, ...infer rest]
172
+ ? Some<rest, value>
173
+ : false;
174
+
175
+ /**
176
+ * @description Creates a type that extracts the values of T.
177
+ *
178
+ * @example
179
+ * ValueOf<{ a: string, b: number }>
180
+ * => string | number
181
+ *
182
+ * @internal
183
+ */
184
+ export type ValueOf<T> = T[keyof T];
185
+
186
+ export type UnionToTuple<
187
+ union,
188
+ ///
189
+ last = LastInUnion<union>,
190
+ > = [union] extends [never] ? [] : [...UnionToTuple<Exclude<union, last>>, last];
191
+ type LastInUnion<U> =
192
+ UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer l) => 0
193
+ ? l
194
+ : never;
195
+ type UnionToIntersection<union> = (union extends unknown ? (arg: union) => 0 : never) extends (
196
+ arg: infer i,
197
+ ) => 0
198
+ ? i
199
+ : never;
200
+
201
+ export type IsUnion<
202
+ union,
203
+ ///
204
+ union2 = union,
205
+ > = union extends union2 ? ([union2] extends [union] ? false : true) : never;
206
+
207
+ export type MaybePartial<type, enabled extends boolean | undefined> = enabled extends true
208
+ ? Prettify<ExactPartial<type>>
209
+ : type;
210
+
211
+ export type ExactPartial<type> = {
212
+ [key in keyof type]?: type[key] | undefined;
213
+ };
214
+
215
+ export type ExactRequired<type> = {
216
+ [P in keyof type]-?: Exclude<type[P], undefined>;
217
+ };
218
+
219
+ export type OneOf<
220
+ union extends object,
221
+ fallback extends object | undefined = undefined,
222
+ ///
223
+ keys extends KeyofUnion<union> = KeyofUnion<union>,
224
+ > = union extends infer item
225
+ ? Prettify<
226
+ item & {
227
+ [key in Exclude<keys, keyof item>]?: fallback extends object
228
+ ? key extends keyof fallback
229
+ ? fallback[key]
230
+ : undefined
231
+ : undefined;
232
+ }
233
+ >
234
+ : never;
235
+ type KeyofUnion<type> = type extends type ? keyof type : never;
236
+
237
+ ///////////////////////////////////////////////////////////////////////////
238
+ // Loose types
239
+
240
+ /**
241
+ * Loose version of {@link Omit}
242
+ *
243
+ * @internal
244
+ */
245
+ export type LooseOmit<type, keys extends string> = Pick<type, Exclude<keyof type, keys>>;
246
+
247
+ ///////////////////////////////////////////////////////////////////////////
248
+ // Union types
249
+
250
+ export type UnionEvaluate<type> = type extends object ? Prettify<type> : type;
251
+
252
+ export type UnionLooseOmit<type, keys extends string> = type extends any
253
+ ? LooseOmit<type, keys>
254
+ : never;
255
+
256
+ /**
257
+ * @description Construct a type with the properties of union type T except for those in type K.
258
+ * @example
259
+ * type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
260
+ * => { b: number } | { b: undefined, c: number }
261
+ */
262
+ export type UnionOmit<type, keys extends keyof type> = type extends any ? Omit<type, keys> : never;
263
+
264
+ /**
265
+ * @description Construct a type with the properties of union type T except for those in type K.
266
+ * @example
267
+ * type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
268
+ * => { b: number } | { b: undefined, c: number }
269
+ */
270
+ export type UnionPick<type, keys extends keyof type> = type extends any ? Pick<type, keys> : never;
271
+
272
+ /**
273
+ * @description Creates a type that is a partial of T, but with the required keys K.
274
+ *
275
+ * @example
276
+ * PartialBy<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
277
+ * => { a?: string, b: number } | { a?: string, b: undefined, c: number }
278
+ */
279
+ export type UnionPartialBy<T, K extends keyof T> = T extends any ? PartialBy<T, K> : never;
280
+
281
+ /**
282
+ * @description Creates a type that is T with the required keys K.
283
+ *
284
+ * @example
285
+ * RequiredBy<{ a?: string, b: number } | { a?: string, c?: number }, 'a'>
286
+ * => { a: string, b: number } | { a: string, c?: number }
287
+ */
288
+ export type UnionRequiredBy<T, K extends keyof T> = T extends any ? RequiredBy<T, K> : never;
package/utils/wait.ts ADDED
@@ -0,0 +1,52 @@
1
+ import { TimeoutError } from "../errors.js";
2
+
3
+ /**
4
+ * Options for the wait function
5
+ */
6
+ export type WaitOptions = {
7
+ /** Interval between retries in seconds. Defaults to 0.2 */
8
+ intervalSeconds?: number;
9
+ /** Maximum time to wait before timing out in seconds. Defaults to 10 */
10
+ timeoutSeconds?: number;
11
+ };
12
+
13
+ /**
14
+ * Polls a resource until a terminal condition is met or timeout occurs.
15
+ *
16
+ * @param reload - Function that fetches the latest state of the resource
17
+ * @param isTerminal - Function that determines if the current state is terminal
18
+ * @param transform - Function that transforms the resource into a new type
19
+ * @param options - Configuration options for polling behavior
20
+ * @returns The resource in its terminal state
21
+ * @throws {TimeoutError} If the operation exceeds the timeout duration
22
+ *
23
+ * @example
24
+ * const result = await wait(
25
+ * () => fetchOrderStatus(orderId),
26
+ * (status) => status === 'completed',
27
+ * (status) => status === 'completed' ? { status } : undefined,
28
+ * { timeoutSeconds: 30 }
29
+ * );
30
+ */
31
+ export async function wait<T, K = T>(
32
+ reload: () => Promise<T>,
33
+ isTerminal: (obj: T) => boolean,
34
+ transform: (obj: T) => K = (obj: T) => obj as unknown as K,
35
+ options: WaitOptions = {},
36
+ ): Promise<K> {
37
+ const { intervalSeconds = 0.2, timeoutSeconds = 10 } = options;
38
+ const startTime = Date.now();
39
+
40
+ while (Date.now() - startTime < timeoutSeconds * 1000) {
41
+ const updatedObject = await reload();
42
+
43
+ if (isTerminal(updatedObject)) {
44
+ return transform(updatedObject);
45
+ }
46
+
47
+ await new Promise(resolve => setTimeout(resolve, intervalSeconds * 1000));
48
+ }
49
+ throw new TimeoutError(
50
+ `Operation has not reached a terminal state after ${timeoutSeconds} seconds and may still succeed. Retry with a longer timeout using the timeoutSeconds option.`,
51
+ );
52
+ }
package/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const version = "1.2.0";
@@ -1 +0,0 @@
1
- export * from "./withAuth";
@@ -1,4 +0,0 @@
1
- import * as axiosHooks from "./hooks/axios";
2
- export * from "./utils/http";
3
- export * from "./utils/jwt";
4
- export { axiosHooks };
@@ -1,2 +0,0 @@
1
- export * from "./http";
2
- export * from "./jwt";
@@ -1 +0,0 @@
1
- export { EvmClient } from "./evm";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EvmClient = void 0;
4
- var evm_1 = require("./evm");
5
- Object.defineProperty(exports, "EvmClient", { enumerable: true, get: function () { return evm_1.EvmClient; } });
@@ -1 +0,0 @@
1
- export { SolanaClient } from "./solana";
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import "./analytics";
2
- export { CdpClient } from "./client/cdp";
3
- export { EvmServerAccount, EvmSmartAccount } from "./accounts/types";
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendUserOperation = exports.getUserOperation = exports.prepareUserOperation = exports.getEvmSmartAccount = exports.createEvmSmartAccount = exports.listEvmSmartAccounts = void 0;
4
- const cdpApiClient_1 = require("../../cdpApiClient");
5
- /**
6
- * Lists the Smart Accounts belonging to the developer's CDP Project.
7
- The response is paginated, and by default, returns 20 accounts per page.
8
- * @summary List Smart Accounts
9
- */
10
- const listEvmSmartAccounts = (params, options) => {
11
- return (0, cdpApiClient_1.cdpApiClient)({ url: `/v2/evm/smart-accounts`, method: 'GET',
12
- params
13
- }, options);
14
- };
15
- exports.listEvmSmartAccounts = listEvmSmartAccounts;
16
- /**
17
- * Creates a new Smart Account.
18
- * @summary Create a Smart Account
19
- */
20
- const createEvmSmartAccount = (createEvmSmartAccountBody, options) => {
21
- return (0, cdpApiClient_1.cdpApiClient)({ url: `/v2/evm/smart-accounts`, method: 'POST',
22
- headers: { 'Content-Type': 'application/json', },
23
- data: createEvmSmartAccountBody
24
- }, options);
25
- };
26
- exports.createEvmSmartAccount = createEvmSmartAccount;
27
- /**
28
- * Gets a Smart Account by its address.
29
- * @summary Get a Smart Account by address
30
- */
31
- const getEvmSmartAccount = (address, options) => {
32
- return (0, cdpApiClient_1.cdpApiClient)({ url: `/v2/evm/smart-accounts/${address}`, method: 'GET'
33
- }, options);
34
- };
35
- exports.getEvmSmartAccount = getEvmSmartAccount;
36
- /**
37
- * Prepares a new user operation on a Smart Account for a specific network.
38
- * @summary Prepare a user operation
39
- */
40
- const prepareUserOperation = (address, prepareUserOperationBody, options) => {
41
- return (0, cdpApiClient_1.cdpApiClient)({ url: `/v2/evm/smart-accounts/${address}/user-operations`, method: 'POST',
42
- headers: { 'Content-Type': 'application/json', },
43
- data: prepareUserOperationBody
44
- }, options);
45
- };
46
- exports.prepareUserOperation = prepareUserOperation;
47
- /**
48
- * Gets a user operation by its hash.
49
- * @summary Get a user operation
50
- */
51
- const getUserOperation = (address, userOpHash, options) => {
52
- return (0, cdpApiClient_1.cdpApiClient)({ url: `/v2/evm/smart-accounts/${address}/user-operations/${userOpHash}`, method: 'GET'
53
- }, options);
54
- };
55
- exports.getUserOperation = getUserOperation;
56
- /**
57
- * Sends a user operation with a signature.
58
- * @summary Send a user operation
59
- */
60
- const sendUserOperation = (address, userOpHash, sendUserOperationBody, options) => {
61
- return (0, cdpApiClient_1.cdpApiClient)({ url: `/v2/evm/smart-accounts/${address}/user-operations/${userOpHash}/send`, method: 'POST',
62
- headers: { 'Content-Type': 'application/json', },
63
- data: sendUserOperationBody
64
- }, options);
65
- };
66
- exports.sendUserOperation = sendUserOperation;