@coinbase/cdp-sdk 1.1.2 → 1.3.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 (332) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/LICENSE +21 -0
  3. package/README.md +88 -1
  4. package/{dist → _cjs}/accounts/evm/toEvmServerAccount.js +1 -0
  5. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -0
  6. package/{dist → _cjs}/accounts/evm/toEvmSmartAccount.js +1 -0
  7. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -0
  8. package/{dist → _cjs}/accounts/types.js +1 -0
  9. package/_cjs/accounts/types.js.map +1 -0
  10. package/{dist → _cjs}/actions/evm/sendUserOperation.js +1 -0
  11. package/_cjs/actions/evm/sendUserOperation.js.map +1 -0
  12. package/{dist → _cjs}/actions/evm/waitForUserOperation.js +10 -9
  13. package/_cjs/actions/evm/waitForUserOperation.js.map +1 -0
  14. package/{dist → _cjs}/analytics.js +32 -12
  15. package/_cjs/analytics.js.map +1 -0
  16. package/{dist → _cjs}/auth/errors.js +1 -0
  17. package/_cjs/auth/errors.js.map +1 -0
  18. package/{dist → _cjs}/auth/hooks/axios/index.js +2 -1
  19. package/_cjs/auth/hooks/axios/index.js.map +1 -0
  20. package/{dist → _cjs}/auth/hooks/axios/withAuth.js +4 -2
  21. package/_cjs/auth/hooks/axios/withAuth.js.map +1 -0
  22. package/{dist → _cjs}/auth/index.js +4 -3
  23. package/_cjs/auth/index.js.map +1 -0
  24. package/{dist → _cjs}/auth/utils/http.js +6 -5
  25. package/_cjs/auth/utils/http.js.map +1 -0
  26. package/{dist → _cjs}/auth/utils/index.js +3 -2
  27. package/_cjs/auth/utils/index.js.map +1 -0
  28. package/{dist → _cjs}/auth/utils/jwt.js +4 -3
  29. package/_cjs/auth/utils/jwt.js.map +1 -0
  30. package/_cjs/client/cdp.js +101 -0
  31. package/_cjs/client/cdp.js.map +1 -0
  32. package/_cjs/client/evm/evm.js +641 -0
  33. package/_cjs/client/evm/evm.js.map +1 -0
  34. package/{dist → _cjs}/client/evm/evm.types.js +1 -0
  35. package/_cjs/client/evm/evm.types.js.map +1 -0
  36. package/{dist → _cjs}/client/solana/index.js +3 -2
  37. package/_cjs/client/solana/index.js.map +1 -0
  38. package/{dist → _cjs}/client/solana/solana.js +9 -8
  39. package/_cjs/client/solana/solana.js.map +1 -0
  40. package/{dist → _cjs}/client/solana/solana.types.js +1 -0
  41. package/_cjs/client/solana/solana.types.js.map +1 -0
  42. package/{dist → _cjs}/constants.js +1 -0
  43. package/_cjs/constants.js.map +1 -0
  44. package/{dist → _cjs}/errors.js +1 -0
  45. package/_cjs/errors.js.map +1 -0
  46. package/{dist → _cjs}/index.js +4 -3
  47. package/_cjs/index.js.map +1 -0
  48. package/_cjs/openapi-client/cdpApiClient.js +116 -0
  49. package/_cjs/openapi-client/cdpApiClient.js.map +1 -0
  50. package/{dist → _cjs}/openapi-client/errors.js +44 -3
  51. package/_cjs/openapi-client/errors.js.map +1 -0
  52. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +66 -0
  53. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -0
  54. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +125 -0
  55. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -0
  56. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +160 -0
  57. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -0
  58. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +70 -0
  59. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -0
  60. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +188 -0
  61. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -0
  62. package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js +15 -0
  63. package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -0
  64. package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js +45 -0
  65. package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js.map +1 -0
  66. package/{dist → _cjs}/openapi-client/generated/faucets/faucets.js +20 -14
  67. package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -0
  68. package/{dist → _cjs}/openapi-client/generated/faucets/faucets.msw.js +16 -12
  69. package/_cjs/openapi-client/generated/faucets/faucets.msw.js.map +1 -0
  70. package/{dist → _cjs}/openapi-client/generated/index.msw.js +6 -4
  71. package/_cjs/openapi-client/generated/index.msw.js.map +1 -0
  72. package/{dist → _cjs}/openapi-client/generated/solana-accounts/solana-accounts.js +38 -35
  73. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -0
  74. package/{dist → _cjs}/openapi-client/generated/solana-accounts/solana-accounts.msw.js +68 -35
  75. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -0
  76. package/{dist → _cjs}/openapi-client/index.js +16 -11
  77. package/_cjs/openapi-client/index.js.map +1 -0
  78. package/_cjs/package.json +1 -0
  79. package/{dist → _cjs}/types/calls.js +1 -0
  80. package/_cjs/types/calls.js.map +1 -0
  81. package/{dist → _cjs}/types/contract.js +1 -0
  82. package/_cjs/types/contract.js.map +1 -0
  83. package/{dist → _cjs}/types/misc.js +1 -0
  84. package/_cjs/types/misc.js.map +1 -0
  85. package/{dist → _cjs}/types/multicall.js +1 -0
  86. package/_cjs/types/multicall.js.map +1 -0
  87. package/{dist → _cjs}/types/utils.js +1 -0
  88. package/_cjs/types/utils.js.map +1 -0
  89. package/{dist → _cjs}/utils/wait.js +3 -2
  90. package/_cjs/utils/wait.js.map +1 -0
  91. package/_cjs/version.js +5 -0
  92. package/_cjs/version.js.map +1 -0
  93. package/_esm/accounts/evm/toEvmServerAccount.js +40 -0
  94. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -0
  95. package/_esm/accounts/evm/toEvmSmartAccount.js +22 -0
  96. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -0
  97. package/_esm/accounts/types.js +2 -0
  98. package/_esm/accounts/types.js.map +1 -0
  99. package/_esm/actions/evm/sendUserOperation.js +85 -0
  100. package/_esm/actions/evm/sendUserOperation.js.map +1 -0
  101. package/_esm/actions/evm/waitForUserOperation.js +58 -0
  102. package/_esm/actions/evm/waitForUserOperation.js.map +1 -0
  103. package/_esm/analytics.js +101 -0
  104. package/_esm/analytics.js.map +1 -0
  105. package/_esm/auth/errors.js +57 -0
  106. package/_esm/auth/errors.js.map +1 -0
  107. package/_esm/auth/hooks/axios/index.js +2 -0
  108. package/_esm/auth/hooks/axios/index.js.map +1 -0
  109. package/_esm/auth/hooks/axios/withAuth.js +72 -0
  110. package/_esm/auth/hooks/axios/withAuth.js.map +1 -0
  111. package/_esm/auth/index.js +5 -0
  112. package/_esm/auth/index.js.map +1 -0
  113. package/_esm/auth/utils/http.js +70 -0
  114. package/_esm/auth/utils/http.js.map +1 -0
  115. package/_esm/auth/utils/index.js +3 -0
  116. package/_esm/auth/utils/index.js.map +1 -0
  117. package/_esm/auth/utils/jwt.js +199 -0
  118. package/_esm/auth/utils/jwt.js.map +1 -0
  119. package/{dist → _esm}/client/cdp.js +16 -13
  120. package/_esm/client/cdp.js.map +1 -0
  121. package/{dist → _esm}/client/evm/evm.js +146 -30
  122. package/_esm/client/evm/evm.js.map +1 -0
  123. package/_esm/client/evm/evm.types.js +2 -0
  124. package/_esm/client/evm/evm.types.js.map +1 -0
  125. package/_esm/client/solana/index.js +2 -0
  126. package/_esm/client/solana/index.js.map +1 -0
  127. package/_esm/client/solana/solana.js +204 -0
  128. package/_esm/client/solana/solana.js.map +1 -0
  129. package/_esm/client/solana/solana.types.js +2 -0
  130. package/_esm/client/solana/solana.types.js.map +1 -0
  131. package/_esm/constants.js +5 -0
  132. package/_esm/constants.js.map +1 -0
  133. package/_esm/errors.js +18 -0
  134. package/_esm/errors.js.map +1 -0
  135. package/_esm/index.js +3 -0
  136. package/_esm/index.js.map +1 -0
  137. package/_esm/openapi-client/cdpApiClient.js +108 -0
  138. package/_esm/openapi-client/cdpApiClient.js.map +1 -0
  139. package/_esm/openapi-client/errors.js +104 -0
  140. package/_esm/openapi-client/errors.js.map +1 -0
  141. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +63 -0
  142. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -0
  143. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +114 -0
  144. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -0
  145. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +140 -0
  146. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -0
  147. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +61 -0
  148. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -0
  149. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +172 -0
  150. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -0
  151. package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js +11 -0
  152. package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -0
  153. package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js +39 -0
  154. package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.msw.js.map +1 -0
  155. package/_esm/openapi-client/generated/faucets/faucets.js +52 -0
  156. package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -0
  157. package/_esm/openapi-client/generated/faucets/faucets.msw.js +39 -0
  158. package/_esm/openapi-client/generated/faucets/faucets.msw.js.map +1 -0
  159. package/_esm/openapi-client/generated/index.msw.js +6 -0
  160. package/_esm/openapi-client/generated/index.msw.js.map +1 -0
  161. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +73 -0
  162. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -0
  163. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +116 -0
  164. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -0
  165. package/_esm/openapi-client/index.js +31 -0
  166. package/_esm/openapi-client/index.js.map +1 -0
  167. package/_esm/package.json +1 -0
  168. package/_esm/types/calls.js +4 -0
  169. package/_esm/types/calls.js.map +1 -0
  170. package/_esm/types/contract.js +4 -0
  171. package/_esm/types/contract.js.map +1 -0
  172. package/_esm/types/misc.js +3 -0
  173. package/_esm/types/misc.js.map +1 -0
  174. package/_esm/types/multicall.js +2 -0
  175. package/_esm/types/multicall.js.map +1 -0
  176. package/_esm/types/utils.js +4 -0
  177. package/_esm/types/utils.js.map +1 -0
  178. package/_esm/utils/wait.js +32 -0
  179. package/_esm/utils/wait.js.map +1 -0
  180. package/_esm/version.js +2 -0
  181. package/_esm/version.js.map +1 -0
  182. package/{dist → _types}/accounts/evm/toEvmServerAccount.d.ts +3 -2
  183. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -0
  184. package/{dist → _types}/accounts/evm/toEvmSmartAccount.d.ts +3 -2
  185. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -0
  186. package/{dist → _types}/accounts/types.d.ts +3 -2
  187. package/_types/accounts/types.d.ts.map +1 -0
  188. package/{dist → _types}/actions/evm/sendUserOperation.d.ts +5 -5
  189. package/_types/actions/evm/sendUserOperation.d.ts.map +1 -0
  190. package/{dist → _types}/actions/evm/waitForUserOperation.d.ts +4 -3
  191. package/_types/actions/evm/waitForUserOperation.d.ts.map +1 -0
  192. package/{dist → _types}/analytics.d.ts +16 -0
  193. package/_types/analytics.d.ts.map +1 -0
  194. package/{dist → _types}/auth/errors.d.ts +1 -0
  195. package/_types/auth/errors.d.ts.map +1 -0
  196. package/_types/auth/hooks/axios/index.d.ts +2 -0
  197. package/_types/auth/hooks/axios/index.d.ts.map +1 -0
  198. package/{dist → _types}/auth/hooks/axios/withAuth.d.ts +1 -0
  199. package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -0
  200. package/_types/auth/index.d.ts +5 -0
  201. package/_types/auth/index.d.ts.map +1 -0
  202. package/{dist → _types}/auth/utils/http.d.ts +1 -0
  203. package/_types/auth/utils/http.d.ts.map +1 -0
  204. package/_types/auth/utils/index.d.ts +3 -0
  205. package/_types/auth/utils/index.d.ts.map +1 -0
  206. package/{dist → _types}/auth/utils/jwt.d.ts +1 -0
  207. package/_types/auth/utils/jwt.d.ts.map +1 -0
  208. package/{dist → _types}/client/cdp.d.ts +3 -2
  209. package/_types/client/cdp.d.ts.map +1 -0
  210. package/{dist → _types}/client/evm/evm.d.ts +86 -3
  211. package/_types/client/evm/evm.d.ts.map +1 -0
  212. package/{dist → _types}/client/evm/evm.types.d.ts +104 -7
  213. package/_types/client/evm/evm.types.d.ts.map +1 -0
  214. package/_types/client/solana/index.d.ts +2 -0
  215. package/_types/client/solana/index.d.ts.map +1 -0
  216. package/{dist → _types}/client/solana/solana.d.ts +2 -1
  217. package/_types/client/solana/solana.d.ts.map +1 -0
  218. package/{dist → _types}/client/solana/solana.types.d.ts +2 -1
  219. package/_types/client/solana/solana.types.d.ts.map +1 -0
  220. package/{dist → _types}/constants.d.ts +1 -0
  221. package/_types/constants.d.ts.map +1 -0
  222. package/{dist → _types}/errors.d.ts +1 -0
  223. package/_types/errors.d.ts.map +1 -0
  224. package/_types/index.d.ts +4 -0
  225. package/_types/index.d.ts.map +1 -0
  226. package/{dist → _types}/openapi-client/cdpApiClient.d.ts +1 -0
  227. package/_types/openapi-client/cdpApiClient.d.ts.map +1 -0
  228. package/{dist → _types}/openapi-client/errors.d.ts +30 -2
  229. package/_types/openapi-client/errors.d.ts.map +1 -0
  230. package/{dist → _types}/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +100 -14
  231. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -0
  232. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +91 -0
  233. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -0
  234. package/{dist → _types}/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -2
  235. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -0
  236. package/{dist → _types}/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +22 -20
  237. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -0
  238. package/{dist → _types}/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +3 -2
  239. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -0
  240. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +20 -0
  241. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -0
  242. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.msw.d.ts +6 -0
  243. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.msw.d.ts.map +1 -0
  244. package/{dist → _types}/openapi-client/generated/faucets/faucets.d.ts +11 -9
  245. package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -0
  246. package/{dist → _types}/openapi-client/generated/faucets/faucets.msw.d.ts +3 -2
  247. package/_types/openapi-client/generated/faucets/faucets.msw.d.ts.map +1 -0
  248. package/_types/openapi-client/generated/index.msw.d.ts +6 -0
  249. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -0
  250. package/{dist → _types}/openapi-client/generated/solana-accounts/solana-accounts.d.ts +21 -20
  251. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -0
  252. package/{dist → _types}/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +3 -2
  253. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -0
  254. package/_types/openapi-client/index.d.ts +61 -0
  255. package/_types/openapi-client/index.d.ts.map +1 -0
  256. package/{dist → _types}/types/calls.d.ts +4 -3
  257. package/_types/types/calls.d.ts.map +1 -0
  258. package/{dist → _types}/types/contract.d.ts +3 -2
  259. package/_types/types/contract.d.ts.map +1 -0
  260. package/_types/types/misc.d.ts +41 -0
  261. package/_types/types/misc.d.ts.map +1 -0
  262. package/{dist → _types}/types/multicall.d.ts +2 -1
  263. package/_types/types/multicall.d.ts.map +1 -0
  264. package/{dist → _types}/types/utils.d.ts +1 -0
  265. package/_types/types/utils.d.ts.map +1 -0
  266. package/{dist → _types}/utils/wait.d.ts +1 -0
  267. package/_types/utils/wait.d.ts.map +1 -0
  268. package/_types/version.d.ts +2 -0
  269. package/_types/version.d.ts.map +1 -0
  270. package/accounts/evm/toEvmServerAccount.ts +60 -0
  271. package/accounts/evm/toEvmSmartAccount.ts +37 -0
  272. package/accounts/types.ts +53 -0
  273. package/actions/evm/sendUserOperation.ts +163 -0
  274. package/actions/evm/waitForUserOperation.ts +115 -0
  275. package/analytics.ts +142 -0
  276. package/auth/README.md +145 -0
  277. package/auth/errors.ts +59 -0
  278. package/auth/hooks/axios/index.ts +1 -0
  279. package/auth/hooks/axios/withAuth.ts +121 -0
  280. package/auth/index.ts +5 -0
  281. package/auth/utils/http.ts +146 -0
  282. package/auth/utils/index.ts +2 -0
  283. package/auth/utils/jwt.ts +324 -0
  284. package/client/cdp.ts +116 -0
  285. package/client/evm/evm.ts +739 -0
  286. package/client/evm/evm.types.ts +408 -0
  287. package/client/solana/index.ts +1 -0
  288. package/client/solana/solana.ts +237 -0
  289. package/client/solana/solana.types.ts +114 -0
  290. package/constants.ts +4 -0
  291. package/errors.ts +17 -0
  292. package/index.ts +4 -0
  293. package/openapi-client/cdpApiClient.ts +221 -0
  294. package/openapi-client/errors.ts +132 -0
  295. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +512 -0
  296. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +271 -0
  297. package/openapi-client/generated/evm-accounts/evm-accounts.ts +194 -0
  298. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +283 -0
  299. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +132 -0
  300. package/openapi-client/generated/evm-token-balances/evm-token-balances.msw.ts +57 -0
  301. package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +37 -0
  302. package/openapi-client/generated/faucets/faucets.msw.ts +76 -0
  303. package/openapi-client/generated/faucets/faucets.ts +84 -0
  304. package/openapi-client/generated/index.msw.ts +5 -0
  305. package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +219 -0
  306. package/openapi-client/generated/solana-accounts/solana-accounts.ts +143 -0
  307. package/openapi-client/index.ts +36 -0
  308. package/package.json +31 -66
  309. package/types/calls.ts +40 -0
  310. package/types/contract.ts +126 -0
  311. package/types/misc.ts +44 -0
  312. package/types/multicall.ts +29 -0
  313. package/types/utils.ts +288 -0
  314. package/utils/wait.ts +52 -0
  315. package/version.ts +1 -0
  316. package/dist/auth/hooks/axios/index.d.ts +0 -1
  317. package/dist/auth/index.d.ts +0 -4
  318. package/dist/auth/utils/index.d.ts +0 -2
  319. package/dist/client/evm/index.d.ts +0 -1
  320. package/dist/client/evm/index.js +0 -5
  321. package/dist/client/solana/index.d.ts +0 -1
  322. package/dist/index.d.ts +0 -3
  323. package/dist/openapi-client/cdpApiClient.js +0 -146
  324. package/dist/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +0 -54
  325. package/dist/openapi-client/generated/evm-accounts/evm-accounts.d.ts +0 -62
  326. package/dist/openapi-client/generated/evm-accounts/evm-accounts.js +0 -85
  327. package/dist/openapi-client/generated/evm-accounts/evm-accounts.msw.js +0 -113
  328. package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +0 -66
  329. package/dist/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +0 -99
  330. package/dist/openapi-client/generated/index.msw.d.ts +0 -4
  331. package/dist/openapi-client/index.d.ts +0 -55
  332. package/dist/types/misc.d.ts +0 -3
@@ -0,0 +1,114 @@
1
+ import {
2
+ OpenApiSolanaMethods,
3
+ SolanaAccount as OpenAPISolanaAccount,
4
+ } from "../../openapi-client/index.js";
5
+ /**
6
+ * The SolanaClient type, where all OpenApiSolanaMethods methods are wrapped.
7
+ */
8
+ export type SolanaClientInterface = Omit<
9
+ typeof OpenApiSolanaMethods,
10
+ | "createSolanaAccount" // mapped to createAccount
11
+ | "getSolanaAccount" // mapped to getAccount
12
+ | "getSolanaAccountByName" // mapped to getAccount
13
+ | "listSolanaAccounts" // mapped to listAccounts
14
+ | "requestSolanaFaucet" // mapped to requestFaucet
15
+ | "signSolanaMessage" // mapped to signMessage
16
+ | "signSolanaTransaction" // mapped to signTransaction
17
+ > & {
18
+ createAccount: (options: CreateAccountOptions) => Promise<Account>;
19
+ getAccount: (options: GetAccountOptions) => Promise<Account>;
20
+ listAccounts: (options: ListAccountsOptions) => Promise<ListAccountsResult>;
21
+ requestFaucet: (options: RequestFaucetOptions) => Promise<SignatureResult>;
22
+ signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
23
+ signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
24
+ };
25
+ /**
26
+ * A Solana account.
27
+ */
28
+ export type Account = OpenAPISolanaAccount;
29
+
30
+ /**
31
+ * Options for creating a Solana account.
32
+ */
33
+ export interface CreateAccountOptions {
34
+ /** The name of the account. */
35
+ name?: string;
36
+ /** The idempotency key. */
37
+ idempotencyKey?: string;
38
+ }
39
+
40
+ /**
41
+ * Options for getting a Solana account.
42
+ */
43
+ export interface GetAccountOptions {
44
+ /** The address of the account. */
45
+ address?: string;
46
+ /** The name of the account. */
47
+ name?: string;
48
+ }
49
+
50
+ /**
51
+ * Options for listing Solana accounts.
52
+ */
53
+ export interface ListAccountsOptions {
54
+ /** The page size. */
55
+ pageSize?: number;
56
+ /** The page token. */
57
+ pageToken?: string;
58
+ }
59
+
60
+ /**
61
+ * The result of listing Solana accounts.
62
+ */
63
+ export interface ListAccountsResult {
64
+ /** The accounts. */
65
+ accounts: Account[];
66
+ /**
67
+ * The token for the next page of accounts, if any.
68
+ */
69
+ nextPageToken?: string;
70
+ }
71
+
72
+ /**
73
+ * Options for requesting funds from a Solana faucet.
74
+ */
75
+ export interface RequestFaucetOptions {
76
+ /** The address of the account. */
77
+ address: string;
78
+ /** The token to request funds for. */
79
+ token: "sol" | "usdc";
80
+ /** The idempotency key. */
81
+ idempotencyKey?: string;
82
+ }
83
+
84
+ /**
85
+ * Options for signing a Solana message.
86
+ */
87
+ export interface SignMessageOptions {
88
+ /** The address of the account. */
89
+ address: string;
90
+ /** The message to sign. */
91
+ message: string;
92
+ /** The idempotency key. */
93
+ idempotencyKey?: string;
94
+ }
95
+
96
+ /**
97
+ * Options for signing a Solana transaction.
98
+ */
99
+ export interface SignTransactionOptions {
100
+ /** The address of the account. */
101
+ address: string;
102
+ /** The base64 encoded transaction to sign. */
103
+ transaction: string;
104
+ /** The idempotency key. */
105
+ idempotencyKey?: string;
106
+ }
107
+
108
+ /**
109
+ * A Solana signature result.
110
+ */
111
+ export interface SignatureResult {
112
+ /** The signature. */
113
+ signature: string;
114
+ }
package/constants.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The URL to the Coinbase CDP API error docs page.
3
+ */
4
+ export const ERROR_DOCS_PAGE_URL = "https://docs.cdp.coinbase.com/api-v2/docs/errors";
package/errors.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * TimeoutError is thrown when an operation times out.
3
+ */
4
+ export class TimeoutError extends Error {
5
+ /**
6
+ * Initializes a new TimeoutError instance.
7
+ *
8
+ * @param message - The error message.
9
+ */
10
+ constructor(message: string = "Timeout Error") {
11
+ super(message);
12
+ this.name = "TimeoutError";
13
+ if (Error.captureStackTrace) {
14
+ Error.captureStackTrace(this, TimeoutError);
15
+ }
16
+ }
17
+ }
package/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ import "./analytics.js";
2
+
3
+ export { CdpClient } from "./client/cdp.js";
4
+ export type { EvmServerAccount, EvmSmartAccount } from "./accounts/types.js";
@@ -0,0 +1,221 @@
1
+ // eslint-disable-next-line import/no-named-as-default
2
+ import Axios, { AxiosInstance, AxiosRequestConfig } from "axios";
3
+
4
+ import { withAuth } from "../auth/hooks/axios/index.js";
5
+ import { ERROR_DOCS_PAGE_URL } from "../constants.js";
6
+ import {
7
+ isOpenAPIError,
8
+ APIError,
9
+ HttpErrorType,
10
+ UnknownApiError,
11
+ UnknownError,
12
+ } from "./errors.js";
13
+
14
+ /**
15
+ * The options for the CDP API.
16
+ */
17
+ export type CdpOptions = {
18
+ /**
19
+ * The API key ID or the legacy API key name.
20
+ *
21
+ * Examples:
22
+ * ID format: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
23
+ * Legacy name format: 'organizations/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/apiKeys/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
24
+ */
25
+ apiKeyId: string;
26
+
27
+ /**
28
+ * The API key secret, using the Ed25519 or legacy EC key format.
29
+ *
30
+ * Examples:
31
+ * Ed25519 key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=='
32
+ * EC key: '-----BEGIN EC PRIVATE KEY-----\n...\n...\n...==\n-----END EC PRIVATE KEY-----\n'
33
+ */
34
+ apiKeySecret: string;
35
+
36
+ /** The Wallet Secret. Only needed if calling certain Wallet APIs. */
37
+ walletSecret?: string;
38
+
39
+ /** If true, logs API requests and responses to the console. */
40
+ debugging?: boolean;
41
+
42
+ /** The base path for the API. */
43
+ basePath?: string;
44
+
45
+ /** The source for the API request, used for analytics. Defaults to `typescript-client`. */
46
+ source?: string;
47
+
48
+ /** The version of the source for the API request, used for analytics. */
49
+ sourceVersion?: string;
50
+
51
+ /** Optional expiration time in seconds (defaults to 120) */
52
+ expiresIn?: number;
53
+ };
54
+
55
+ let axiosInstance: AxiosInstance;
56
+
57
+ /**
58
+ * Configures the CDP client with the given options.
59
+ *
60
+ * @param {CdpOptions} options - The CDP options.
61
+ */
62
+ export const configure = (options: CdpOptions) => {
63
+ axiosInstance = Axios.create({
64
+ baseURL: options.basePath || "https://api.cdp.coinbase.com/platform",
65
+ });
66
+
67
+ axiosInstance = withAuth(axiosInstance, {
68
+ apiKeyId: options.apiKeyId,
69
+ apiKeySecret: options.apiKeySecret,
70
+ source: options.source || "sdk-openapi-client",
71
+ sourceVersion: options.sourceVersion,
72
+ walletSecret: options.walletSecret,
73
+ expiresIn: options.expiresIn,
74
+ debug: options.debugging,
75
+ });
76
+ };
77
+
78
+ /**
79
+ * Adds an idempotency key to request config if provided
80
+ *
81
+ * @param config - The Axios request configuration.
82
+ * @param idempotencyKey - The idempotency key.
83
+ * @returns The Axios request configuration with the idempotency key.
84
+ */
85
+ const addIdempotencyKey = (
86
+ config: AxiosRequestConfig,
87
+ idempotencyKey?: string,
88
+ ): AxiosRequestConfig => {
89
+ if (!idempotencyKey) {
90
+ return config;
91
+ }
92
+
93
+ return {
94
+ ...config,
95
+ headers: {
96
+ ...(config.headers || {}),
97
+ "X-Idempotency-Key": idempotencyKey,
98
+ },
99
+ };
100
+ };
101
+
102
+ /**
103
+ * Mutates the given Axios request configuration to add the CDP API key signature
104
+ * to the request headers.
105
+ *
106
+ * @param {AxiosRequestConfig} config - The Axios request configuration.
107
+ * @param idempotencyKey - The idempotency key.
108
+ * @returns {Promise<T>} A promise that resolves to the response data.
109
+ * @throws {APIError} If the request fails.
110
+ */
111
+ export const cdpApiClient = async <T>(
112
+ config: AxiosRequestConfig,
113
+ idempotencyKey?: string,
114
+ ): Promise<T> => {
115
+ validateCall(config);
116
+
117
+ // Add idempotency key to the request headers if provided
118
+ const configWithIdempotencyKey = addIdempotencyKey(config, idempotencyKey);
119
+
120
+ try {
121
+ const response = await axiosInstance(configWithIdempotencyKey);
122
+ return response.data as T;
123
+ } catch (error) {
124
+ // eslint-disable-next-line import/no-named-as-default-member
125
+ if (Axios.isAxiosError(error) && !error.response) {
126
+ throw new UnknownApiError(
127
+ HttpErrorType.unknown,
128
+ error.cause instanceof Error ? error.cause.message : error.message,
129
+ error.cause,
130
+ );
131
+ }
132
+
133
+ // eslint-disable-next-line import/no-named-as-default-member
134
+ if (Axios.isAxiosError(error) && error.response) {
135
+ if (isOpenAPIError(error.response.data)) {
136
+ throw new APIError(
137
+ error.response.status,
138
+ error.response.data.errorType,
139
+ error.response.data.errorMessage,
140
+ error.response.data.correlationId,
141
+ error.response.data.errorLink,
142
+ error.cause,
143
+ );
144
+ } else {
145
+ const statusCode = error.response.status;
146
+ switch (statusCode) {
147
+ case 401:
148
+ throw new APIError(
149
+ statusCode,
150
+ HttpErrorType.unauthorized,
151
+ "Unauthorized.",
152
+ undefined,
153
+ `${ERROR_DOCS_PAGE_URL}#unauthorized`,
154
+ error.cause,
155
+ );
156
+ case 404:
157
+ throw new APIError(
158
+ statusCode,
159
+ HttpErrorType.not_found,
160
+ "API not found.",
161
+ undefined,
162
+ `${ERROR_DOCS_PAGE_URL}#not_found`,
163
+ error.cause,
164
+ );
165
+ case 502:
166
+ throw new APIError(
167
+ statusCode,
168
+ HttpErrorType.bad_gateway,
169
+ "Bad gateway.",
170
+ undefined,
171
+ `${ERROR_DOCS_PAGE_URL}`,
172
+ error.cause,
173
+ );
174
+ case 503:
175
+ throw new APIError(
176
+ statusCode,
177
+ HttpErrorType.service_unavailable,
178
+ "Service unavailable. Please try again later.",
179
+ undefined,
180
+ `${ERROR_DOCS_PAGE_URL}`,
181
+ error.cause,
182
+ );
183
+ default:
184
+ throw new APIError(
185
+ statusCode,
186
+ HttpErrorType.unexpected_error,
187
+ "An unexpected error occurred.",
188
+ undefined,
189
+ `${ERROR_DOCS_PAGE_URL}`,
190
+ error.cause,
191
+ );
192
+ }
193
+ }
194
+ }
195
+
196
+ throw new UnknownError(
197
+ "Something went wrong. Please reach out at https://discord.com/channels/1220414409550336183/1271495764580896789 for help.",
198
+ error instanceof Error ? error : undefined,
199
+ );
200
+ }
201
+ };
202
+
203
+ /**
204
+ * Validates the call to the cdpApiClient.
205
+ *
206
+ * @param {AxiosRequestConfig} config - The Axios request configuration.
207
+ * @throws {Error} If the call is not valid.
208
+ */
209
+ const validateCall = (config: AxiosRequestConfig) => {
210
+ if (!axiosInstance.getUri() || axiosInstance.getUri() === "") {
211
+ throw new Error("CDP client URI not configured. Call configure() first.");
212
+ }
213
+
214
+ if (!config.url || config.url === "") {
215
+ throw new Error("AxiosRequestConfig URL is empty. This should never happen.");
216
+ }
217
+
218
+ if (!config.method || config.method === "") {
219
+ throw new Error("AxiosRequestConfig method is empty. This should never happen.");
220
+ }
221
+ };
@@ -0,0 +1,132 @@
1
+ import {
2
+ Error as OpenAPIError,
3
+ ErrorType as OpenAPIErrorType,
4
+ } from "./generated/coinbaseDeveloperPlatformAPIs.schemas.js";
5
+
6
+ export const HttpErrorType = {
7
+ unexpected_error: "unexpected_error",
8
+ unauthorized: "unauthorized",
9
+ not_found: "not_found",
10
+ bad_gateway: "bad_gateway",
11
+ service_unavailable: "service_unavailable",
12
+ unknown: "unknown",
13
+ } as const;
14
+
15
+ export type HttpErrorType = (typeof HttpErrorType)[keyof typeof HttpErrorType];
16
+
17
+ /**
18
+ * Extended error codes that include both OpenAPI errors and network errors
19
+ */
20
+ export type APIErrorType = OpenAPIErrorType | HttpErrorType;
21
+
22
+ /**
23
+ * Extended API error that encompasses both OpenAPI errors and other API-related errors
24
+ */
25
+ export class APIError extends Error {
26
+ statusCode: number;
27
+ errorType: APIErrorType;
28
+ errorMessage: string;
29
+ correlationId?: string;
30
+ errorLink?: string;
31
+
32
+ /**
33
+ * Constructor for the APIError class
34
+ *
35
+ * @param statusCode - The HTTP status code
36
+ * @param errorType - The type of error
37
+ * @param errorMessage - The error message
38
+ * @param correlationId - The correlation ID
39
+ * @param errorLink - URL to documentation about this error
40
+ * @param cause - The cause of the error
41
+ */
42
+ constructor(
43
+ statusCode: number,
44
+ errorType: APIErrorType,
45
+ errorMessage: string,
46
+ correlationId?: string,
47
+ errorLink?: string,
48
+ cause?: Error,
49
+ ) {
50
+ super(errorMessage, { cause });
51
+ this.name = "APIError";
52
+ this.statusCode = statusCode;
53
+ this.errorType = errorType;
54
+ this.errorMessage = errorMessage;
55
+
56
+ // Only set correlationId if it's defined
57
+ if (correlationId !== undefined) {
58
+ this.correlationId = correlationId;
59
+ }
60
+
61
+ // Only set errorLink if it's defined
62
+ if (errorLink !== undefined) {
63
+ this.errorLink = errorLink;
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Convert the error to a JSON object, excluding undefined properties
69
+ *
70
+ * @returns The error as a JSON object
71
+ */
72
+ toJSON() {
73
+ return {
74
+ name: this.name,
75
+ statusCode: this.statusCode,
76
+ errorType: this.errorType,
77
+ errorMessage: this.errorMessage,
78
+ ...(this.correlationId && { correlationId: this.correlationId }),
79
+ ...(this.errorLink && { errorLink: this.errorLink }),
80
+ };
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Error thrown when an Axios request is made but no response is received
86
+ */
87
+ export class UnknownApiError extends APIError {
88
+ /**
89
+ * Constructor for the UnknownApiError class
90
+ *
91
+ * @param errorType - The type of error
92
+ * @param errorMessage - The error message
93
+ * @param cause - The cause of the error
94
+ */
95
+ constructor(errorType: APIErrorType, errorMessage: string, cause?: Error) {
96
+ super(0, errorType, errorMessage, undefined, undefined, cause);
97
+ this.name = "UnknownApiError";
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Error thrown when an error is not known
103
+ */
104
+ export class UnknownError extends Error {
105
+ /**
106
+ * Constructor for the UnknownError class
107
+ *
108
+ * @param message - The error message
109
+ * @param cause - The cause of the error
110
+ */
111
+ constructor(message: string, cause?: Error) {
112
+ super(message, { cause });
113
+ this.name = "UnknownError";
114
+ }
115
+ }
116
+
117
+ /**
118
+ * Type guard to check if an object is an OpenAPIError
119
+ *
120
+ * @param obj - The object to check
121
+ * @returns True if the object is an OpenAPIError
122
+ */
123
+ export function isOpenAPIError(obj: unknown): obj is OpenAPIError {
124
+ return (
125
+ obj !== null &&
126
+ typeof obj === "object" &&
127
+ "errorType" in obj &&
128
+ typeof (obj as OpenAPIError).errorType === "string" &&
129
+ "errorMessage" in obj &&
130
+ typeof (obj as OpenAPIError).errorMessage === "string"
131
+ );
132
+ }