@coinbase/cdp-sdk 1.44.1 → 1.46.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 (282) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/README.md +164 -43
  3. package/_cjs/accounts/evm/eip6492.js +49 -0
  4. package/_cjs/accounts/evm/eip6492.js.map +1 -0
  5. package/_cjs/accounts/evm/toEvmDelegatedAccount.js +27 -0
  6. package/_cjs/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
  7. package/_cjs/accounts/evm/toEvmServerAccount.js +127 -55
  8. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  9. package/_cjs/accounts/evm/toEvmSmartAccount.js +115 -45
  10. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  11. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
  12. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  13. package/_cjs/accounts/solana/toSolanaAccount.js +49 -19
  14. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  15. package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js +37 -0
  16. package/_cjs/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
  17. package/_cjs/actions/solana/transfer.js.map +1 -1
  18. package/_cjs/actions/solana/utils.js +9 -9
  19. package/_cjs/actions/solana/utils.js.map +1 -1
  20. package/_cjs/analytics.js +10 -228
  21. package/_cjs/analytics.js.map +1 -1
  22. package/_cjs/auth/utils/http.js +1 -0
  23. package/_cjs/auth/utils/http.js.map +1 -1
  24. package/_cjs/client/cdp.js +4 -7
  25. package/_cjs/client/cdp.js.map +1 -1
  26. package/_cjs/client/end-user/endUser.js +385 -4
  27. package/_cjs/client/end-user/endUser.js.map +1 -1
  28. package/_cjs/client/end-user/toEndUserAccount.js +201 -23
  29. package/_cjs/client/end-user/toEndUserAccount.js.map +1 -1
  30. package/_cjs/client/evm/evm.js +482 -227
  31. package/_cjs/client/evm/evm.js.map +1 -1
  32. package/_cjs/client/policies/policies.js +41 -11
  33. package/_cjs/client/policies/policies.js.map +1 -1
  34. package/_cjs/client/solana/solana.js +215 -118
  35. package/_cjs/client/solana/solana.js.map +1 -1
  36. package/_cjs/index.js +3 -1
  37. package/_cjs/index.js.map +1 -1
  38. package/_cjs/openapi-client/cdpApiClient.js +32 -0
  39. package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
  40. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +178 -9
  41. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  42. package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js +261 -0
  43. package/_cjs/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
  44. package/_cjs/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
  45. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +30 -1
  46. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  47. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
  48. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  49. package/_cjs/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
  50. package/_cjs/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
  51. package/_cjs/openapi-client/generated/faucets/faucets.js +6 -5
  52. package/_cjs/openapi-client/generated/faucets/faucets.js.map +1 -1
  53. package/_cjs/openapi-client/generated/onchain-data/onchain-data.js.map +1 -1
  54. package/_cjs/openapi-client/generated/onramp/onramp.js +15 -1
  55. package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -1
  56. package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
  57. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  58. package/_cjs/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
  59. package/_cjs/openapi-client/generated/sql-api/sql-api.js +75 -0
  60. package/_cjs/openapi-client/generated/sql-api/sql-api.js.map +1 -0
  61. package/_cjs/openapi-client/generated/webhooks/webhooks.js.map +1 -1
  62. package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
  63. package/_cjs/openapi-client/index.js +4 -1
  64. package/_cjs/openapi-client/index.js.map +1 -1
  65. package/_cjs/policies/evmSchema.js +127 -1
  66. package/_cjs/policies/evmSchema.js.map +1 -1
  67. package/_cjs/policies/solanaSchema.js +102 -1
  68. package/_cjs/policies/solanaSchema.js.map +1 -1
  69. package/_cjs/policies/types.js +7 -0
  70. package/_cjs/policies/types.js.map +1 -1
  71. package/_cjs/utils/export.js +6 -5
  72. package/_cjs/utils/export.js.map +1 -1
  73. package/_cjs/version.js +1 -1
  74. package/_esm/accounts/evm/eip6492.js +46 -0
  75. package/_esm/accounts/evm/eip6492.js.map +1 -0
  76. package/_esm/accounts/evm/toEvmDelegatedAccount.js +24 -0
  77. package/_esm/accounts/evm/toEvmDelegatedAccount.js.map +1 -0
  78. package/_esm/accounts/evm/toEvmServerAccount.js +127 -55
  79. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  80. package/_esm/accounts/evm/toEvmSmartAccount.js +115 -45
  81. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  82. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +31 -0
  83. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  84. package/_esm/accounts/solana/toSolanaAccount.js +49 -19
  85. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  86. package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js +34 -0
  87. package/_esm/actions/evm/waitForEvmEip7702DelegationStatus.js.map +1 -0
  88. package/_esm/actions/solana/transfer.js.map +1 -1
  89. package/_esm/actions/solana/utils.js +9 -9
  90. package/_esm/actions/solana/utils.js.map +1 -1
  91. package/_esm/analytics.js +9 -227
  92. package/_esm/analytics.js.map +1 -1
  93. package/_esm/auth/utils/http.js +1 -0
  94. package/_esm/auth/utils/http.js.map +1 -1
  95. package/_esm/client/cdp.js +4 -7
  96. package/_esm/client/cdp.js.map +1 -1
  97. package/_esm/client/end-user/endUser.js +385 -4
  98. package/_esm/client/end-user/endUser.js.map +1 -1
  99. package/_esm/client/end-user/toEndUserAccount.js +201 -23
  100. package/_esm/client/end-user/toEndUserAccount.js.map +1 -1
  101. package/_esm/client/evm/evm.js +482 -227
  102. package/_esm/client/evm/evm.js.map +1 -1
  103. package/_esm/client/policies/policies.js +41 -11
  104. package/_esm/client/policies/policies.js.map +1 -1
  105. package/_esm/client/solana/solana.js +215 -118
  106. package/_esm/client/solana/solana.js.map +1 -1
  107. package/_esm/index.js +1 -0
  108. package/_esm/index.js.map +1 -1
  109. package/_esm/openapi-client/cdpApiClient.js +32 -0
  110. package/_esm/openapi-client/cdpApiClient.js.map +1 -1
  111. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +175 -7
  112. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  113. package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js +243 -0
  114. package/_esm/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.js.map +1 -0
  115. package/_esm/openapi-client/generated/end-user-accounts/end-user-accounts.js.map +1 -1
  116. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +27 -0
  117. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  118. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +2 -2
  119. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  120. package/_esm/openapi-client/generated/evm-swaps/evm-swaps.js.map +1 -1
  121. package/_esm/openapi-client/generated/evm-token-balances/evm-token-balances.js.map +1 -1
  122. package/_esm/openapi-client/generated/faucets/faucets.js +6 -5
  123. package/_esm/openapi-client/generated/faucets/faucets.js.map +1 -1
  124. package/_esm/openapi-client/generated/onchain-data/onchain-data.js.map +1 -1
  125. package/_esm/openapi-client/generated/onramp/onramp.js +13 -0
  126. package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -1
  127. package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -1
  128. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  129. package/_esm/openapi-client/generated/solana-token-balances/solana-token-balances.js.map +1 -1
  130. package/_esm/openapi-client/generated/sql-api/sql-api.js +70 -0
  131. package/_esm/openapi-client/generated/sql-api/sql-api.js.map +1 -0
  132. package/_esm/openapi-client/generated/webhooks/webhooks.js.map +1 -1
  133. package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -1
  134. package/_esm/openapi-client/index.js +4 -1
  135. package/_esm/openapi-client/index.js.map +1 -1
  136. package/_esm/policies/evmSchema.js +126 -0
  137. package/_esm/policies/evmSchema.js.map +1 -1
  138. package/_esm/policies/solanaSchema.js +101 -0
  139. package/_esm/policies/solanaSchema.js.map +1 -1
  140. package/_esm/policies/types.js +9 -2
  141. package/_esm/policies/types.js.map +1 -1
  142. package/_esm/utils/export.js +6 -5
  143. package/_esm/utils/export.js.map +1 -1
  144. package/_esm/version.js +1 -1
  145. package/_types/accounts/evm/eip6492.d.ts +17 -0
  146. package/_types/accounts/evm/eip6492.d.ts.map +1 -0
  147. package/_types/accounts/evm/toEvmDelegatedAccount.d.ts +13 -0
  148. package/_types/accounts/evm/toEvmDelegatedAccount.d.ts.map +1 -0
  149. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  150. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  151. package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts +4 -4
  152. package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
  153. package/_types/accounts/evm/types.d.ts +3 -2
  154. package/_types/accounts/evm/types.d.ts.map +1 -1
  155. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  156. package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts +32 -0
  157. package/_types/actions/evm/waitForEvmEip7702DelegationStatus.d.ts.map +1 -0
  158. package/_types/actions/solana/transfer.d.ts +3 -4
  159. package/_types/actions/solana/transfer.d.ts.map +1 -1
  160. package/_types/actions/solana/types.d.ts +79 -29
  161. package/_types/actions/solana/types.d.ts.map +1 -1
  162. package/_types/actions/solana/utils.d.ts +10 -9
  163. package/_types/actions/solana/utils.d.ts.map +1 -1
  164. package/_types/analytics.d.ts +5 -38
  165. package/_types/analytics.d.ts.map +1 -1
  166. package/_types/auth/utils/http.d.ts.map +1 -1
  167. package/_types/client/cdp.d.ts +4 -0
  168. package/_types/client/cdp.d.ts.map +1 -1
  169. package/_types/client/end-user/endUser.d.ts +272 -1
  170. package/_types/client/end-user/endUser.d.ts.map +1 -1
  171. package/_types/client/end-user/endUser.types.d.ts +491 -1
  172. package/_types/client/end-user/endUser.types.d.ts.map +1 -1
  173. package/_types/client/end-user/toEndUserAccount.d.ts +4 -1
  174. package/_types/client/end-user/toEndUserAccount.d.ts.map +1 -1
  175. package/_types/client/evm/evm.d.ts +54 -1
  176. package/_types/client/evm/evm.d.ts.map +1 -1
  177. package/_types/client/evm/evm.types.d.ts +29 -2
  178. package/_types/client/evm/evm.types.d.ts.map +1 -1
  179. package/_types/client/policies/policies.d.ts.map +1 -1
  180. package/_types/client/solana/solana.d.ts +38 -12
  181. package/_types/client/solana/solana.d.ts.map +1 -1
  182. package/_types/index.d.ts +3 -1
  183. package/_types/index.d.ts.map +1 -1
  184. package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
  185. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +884 -90
  186. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  187. package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts +163 -0
  188. package/_types/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.d.ts.map +1 -0
  189. package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts +9 -9
  190. package/_types/openapi-client/generated/end-user-accounts/end-user-accounts.d.ts.map +1 -1
  191. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +35 -15
  192. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  193. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +14 -14
  194. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  195. package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts +3 -3
  196. package/_types/openapi-client/generated/evm-swaps/evm-swaps.d.ts.map +1 -1
  197. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts +2 -2
  198. package/_types/openapi-client/generated/evm-token-balances/evm-token-balances.d.ts.map +1 -1
  199. package/_types/openapi-client/generated/faucets/faucets.d.ts +9 -8
  200. package/_types/openapi-client/generated/faucets/faucets.d.ts.map +1 -1
  201. package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts +3 -3
  202. package/_types/openapi-client/generated/onchain-data/onchain-data.d.ts.map +1 -1
  203. package/_types/openapi-client/generated/onramp/onramp.d.ts +12 -5
  204. package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -1
  205. package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +6 -6
  206. package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -1
  207. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +12 -12
  208. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
  209. package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts +2 -2
  210. package/_types/openapi-client/generated/solana-token-balances/solana-token-balances.d.ts.map +1 -1
  211. package/_types/openapi-client/generated/sql-api/sql-api.d.ts +73 -0
  212. package/_types/openapi-client/generated/sql-api/sql-api.d.ts.map +1 -0
  213. package/_types/openapi-client/generated/webhooks/webhooks.d.ts +6 -6
  214. package/_types/openapi-client/generated/webhooks/webhooks.d.ts.map +1 -1
  215. package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts +4 -4
  216. package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -1
  217. package/_types/openapi-client/index.d.ts +23 -3
  218. package/_types/openapi-client/index.d.ts.map +1 -1
  219. package/_types/policies/evmSchema.d.ts +3128 -1064
  220. package/_types/policies/evmSchema.d.ts.map +1 -1
  221. package/_types/policies/solanaSchema.d.ts +1411 -47
  222. package/_types/policies/solanaSchema.d.ts.map +1 -1
  223. package/_types/policies/types.d.ts +8427 -2942
  224. package/_types/policies/types.d.ts.map +1 -1
  225. package/_types/types/contract.d.ts.map +1 -1
  226. package/_types/utils/export.d.ts +1 -1
  227. package/_types/utils/export.d.ts.map +1 -1
  228. package/_types/version.d.ts +1 -1
  229. package/accounts/evm/eip6492.ts +60 -0
  230. package/accounts/evm/toEvmDelegatedAccount.ts +26 -0
  231. package/accounts/evm/toEvmServerAccount.ts +115 -67
  232. package/accounts/evm/toEvmSmartAccount.ts +114 -57
  233. package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +44 -5
  234. package/accounts/evm/types.ts +8 -3
  235. package/accounts/solana/toSolanaAccount.ts +44 -24
  236. package/actions/evm/waitForEvmEip7702DelegationStatus.ts +57 -0
  237. package/actions/solana/transfer.ts +3 -3
  238. package/actions/solana/types.ts +79 -29
  239. package/actions/solana/utils.ts +13 -11
  240. package/analytics.ts +8 -294
  241. package/auth/utils/http.ts +1 -0
  242. package/client/cdp.ts +6 -8
  243. package/client/end-user/endUser.ts +513 -4
  244. package/client/end-user/endUser.types.ts +598 -0
  245. package/client/end-user/toEndUserAccount.ts +330 -26
  246. package/client/evm/evm.ts +517 -282
  247. package/client/evm/evm.types.ts +45 -2
  248. package/client/policies/policies.ts +41 -16
  249. package/client/solana/solana.ts +233 -153
  250. package/index.ts +36 -1
  251. package/openapi-client/cdpApiClient.ts +34 -0
  252. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +1155 -172
  253. package/openapi-client/generated/embedded-wallets-core-functionality/embedded-wallets-core-functionality.ts +455 -0
  254. package/openapi-client/generated/end-user-accounts/end-user-accounts.ts +12 -9
  255. package/openapi-client/generated/evm-accounts/evm-accounts.ts +66 -14
  256. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +16 -16
  257. package/openapi-client/generated/evm-swaps/evm-swaps.ts +3 -3
  258. package/openapi-client/generated/evm-token-balances/evm-token-balances.ts +2 -2
  259. package/openapi-client/generated/faucets/faucets.ts +9 -8
  260. package/openapi-client/generated/onchain-data/onchain-data.ts +3 -3
  261. package/openapi-client/generated/onramp/onramp.ts +28 -4
  262. package/openapi-client/generated/policy-engine/policy-engine.ts +12 -6
  263. package/openapi-client/generated/solana-accounts/solana-accounts.ts +12 -12
  264. package/openapi-client/generated/solana-token-balances/solana-token-balances.ts +2 -2
  265. package/openapi-client/generated/sql-api/sql-api.ts +92 -0
  266. package/openapi-client/generated/webhooks/webhooks.ts +6 -6
  267. package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +6 -4
  268. package/openapi-client/index.ts +4 -1
  269. package/package.json +7 -8
  270. package/policies/evmSchema.ts +164 -0
  271. package/policies/solanaSchema.ts +130 -0
  272. package/policies/types.ts +14 -0
  273. package/types/contract.ts +2 -4
  274. package/utils/export.ts +6 -5
  275. package/version.ts +1 -1
  276. package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -55
  277. package/_cjs/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
  278. package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js +0 -50
  279. package/_esm/openapi-client/generated/sql-api-alpha/sql-api-alpha.js.map +0 -1
  280. package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts +0 -53
  281. package/_types/openapi-client/generated/sql-api-alpha/sql-api-alpha.d.ts.map +0 -1
  282. package/openapi-client/generated/sql-api-alpha/sql-api-alpha.ts +0 -72
package/client/evm/evm.ts CHANGED
@@ -7,6 +7,7 @@ import { constants, publicEncrypt } from "crypto";
7
7
  import { type Address, getTypesForEIP712Domain } from "viem";
8
8
 
9
9
  import {
10
+ CreateEvmEip7702DelegationResult,
10
11
  CreateServerAccountOptions,
11
12
  CreateSmartAccountOptions,
12
13
  CreateSwapQuoteOptions,
@@ -67,6 +68,7 @@ import {
67
68
  import { resolveSpendPermission } from "../../actions/evm/spend-permissions/resolveSpendPermission.js";
68
69
  import { createSwapQuote } from "../../actions/evm/swap/createSwapQuote.js";
69
70
  import { getSwapPrice } from "../../actions/evm/swap/getSwapPrice.js";
71
+ import { waitForEvmEip7702DelegationOperationStatus } from "../../actions/evm/waitForEvmEip7702DelegationStatus.js";
70
72
  import {
71
73
  waitForUserOperation,
72
74
  WaitForUserOperationReturnType,
@@ -77,6 +79,7 @@ import { UserInputValidationError } from "../../errors.js";
77
79
  import { APIError } from "../../openapi-client/errors.js";
78
80
  import {
79
81
  CdpOpenApiClient,
82
+ EvmEip7702DelegationOperation,
80
83
  EvmUserOperationStatus,
81
84
  EIP712Message as OpenAPIEIP712Message,
82
85
  } from "../../openapi-client/index.js";
@@ -84,6 +87,10 @@ import { SPEND_PERMISSION_MANAGER_ADDRESS } from "../../spend-permissions/consta
84
87
  import { Hex } from "../../types/misc.js";
85
88
  import { decryptWithPrivateKey, generateExportEncryptionKeyPair } from "../../utils/export.js";
86
89
 
90
+ import type {
91
+ CreateEvmEip7702DelegationOptions,
92
+ WaitForEvmEip7702DelegationOperationStatusOptions,
93
+ } from "./evm.types.js";
87
94
  import type {
88
95
  SendTransactionOptions,
89
96
  TransactionResult,
@@ -138,7 +145,12 @@ export class EvmClient implements EvmClientInterface {
138
145
  accountType: "evm_server",
139
146
  });
140
147
 
141
- return this._createAccountInternal(options);
148
+ try {
149
+ return await this._createAccountInternal(options);
150
+ } catch (error) {
151
+ Analytics.trackError(error, "createAccount");
152
+ throw error;
153
+ }
142
154
  }
143
155
 
144
156
  /**
@@ -189,17 +201,17 @@ export class EvmClient implements EvmClientInterface {
189
201
  accountType: "evm_server",
190
202
  });
191
203
 
192
- const encryptionPublicKey = options.encryptionPublicKey || ImportAccountPublicRSAKey;
204
+ try {
205
+ const encryptionPublicKey = options.encryptionPublicKey || ImportAccountPublicRSAKey;
193
206
 
194
- const privateKeyHex = options.privateKey.startsWith("0x")
195
- ? options.privateKey.slice(2)
196
- : options.privateKey;
207
+ const privateKeyHex = options.privateKey.startsWith("0x")
208
+ ? options.privateKey.slice(2)
209
+ : options.privateKey;
197
210
 
198
- if (!/^[0-9a-fA-F]+$/.test(privateKeyHex)) {
199
- throw new UserInputValidationError("Private key must be a valid hexadecimal string");
200
- }
211
+ if (!/^[0-9a-fA-F]+$/.test(privateKeyHex)) {
212
+ throw new UserInputValidationError("Private key must be a valid hexadecimal string");
213
+ }
201
214
 
202
- try {
203
215
  const privateKeyBytes = Buffer.from(privateKeyHex, "hex");
204
216
 
205
217
  const encryptedPrivateKey = publicEncrypt(
@@ -223,10 +235,12 @@ export class EvmClient implements EvmClientInterface {
223
235
  account: openApiAccount,
224
236
  });
225
237
 
226
- Analytics.wrapObjectMethodsWithErrorTracking(account);
227
-
228
238
  return account;
229
239
  } catch (error) {
240
+ if (!(error instanceof UserInputValidationError)) {
241
+ Analytics.trackError(error, "importAccount");
242
+ }
243
+
230
244
  if (error instanceof APIError) {
231
245
  throw error;
232
246
  }
@@ -265,33 +279,40 @@ export class EvmClient implements EvmClientInterface {
265
279
  accountType: "evm_server",
266
280
  });
267
281
 
268
- const { publicKey, privateKey } = await generateExportEncryptionKeyPair();
269
-
270
- const { encryptedPrivateKey } = await (async () => {
271
- if (options.address) {
272
- return CdpOpenApiClient.exportEvmAccount(
273
- options.address,
274
- {
275
- exportEncryptionKey: publicKey,
276
- },
277
- options.idempotencyKey,
278
- );
279
- }
282
+ try {
283
+ const { publicKey, privateKey } = await generateExportEncryptionKeyPair();
284
+
285
+ const { encryptedPrivateKey } = await (async () => {
286
+ if (options.address) {
287
+ return CdpOpenApiClient.exportEvmAccount(
288
+ options.address,
289
+ {
290
+ exportEncryptionKey: publicKey,
291
+ },
292
+ options.idempotencyKey,
293
+ );
294
+ }
280
295
 
281
- if (options.name) {
282
- return CdpOpenApiClient.exportEvmAccountByName(
283
- options.name,
284
- {
285
- exportEncryptionKey: publicKey,
286
- },
287
- options.idempotencyKey,
288
- );
289
- }
296
+ if (options.name) {
297
+ return CdpOpenApiClient.exportEvmAccountByName(
298
+ options.name,
299
+ {
300
+ exportEncryptionKey: publicKey,
301
+ },
302
+ options.idempotencyKey,
303
+ );
304
+ }
290
305
 
291
- throw new UserInputValidationError("Either address or name must be provided");
292
- })();
306
+ throw new UserInputValidationError("Either address or name must be provided");
307
+ })();
293
308
 
294
- return decryptWithPrivateKey(privateKey, encryptedPrivateKey);
309
+ return decryptWithPrivateKey(privateKey, encryptedPrivateKey);
310
+ } catch (error) {
311
+ if (!(error instanceof UserInputValidationError)) {
312
+ Analytics.trackError(error, "exportAccount");
313
+ }
314
+ throw error;
315
+ }
295
316
  }
296
317
 
297
318
  /**
@@ -345,7 +366,12 @@ export class EvmClient implements EvmClientInterface {
345
366
  accountType: "evm_smart",
346
367
  });
347
368
 
348
- return this._createSmartAccountInternal(options);
369
+ try {
370
+ return await this._createSmartAccountInternal(options);
371
+ } catch (error) {
372
+ Analytics.trackError(error, "createSmartAccount");
373
+ throw error;
374
+ }
349
375
  }
350
376
 
351
377
  /**
@@ -370,38 +396,43 @@ export class EvmClient implements EvmClientInterface {
370
396
  action: "create_spend_permission",
371
397
  });
372
398
 
373
- const resolvedSpendPermission = resolveSpendPermission(
374
- options.spendPermission,
375
- options.network,
376
- );
399
+ try {
400
+ const resolvedSpendPermission = resolveSpendPermission(
401
+ options.spendPermission,
402
+ options.network,
403
+ );
377
404
 
378
- const userOperation = await CdpOpenApiClient.createSpendPermission(
379
- resolvedSpendPermission.account,
380
- {
381
- spender: resolvedSpendPermission.spender,
382
- token: resolvedSpendPermission.token,
383
- allowance: resolvedSpendPermission.allowance.toString(),
384
- period: resolvedSpendPermission.period.toString(),
385
- start: resolvedSpendPermission.start.toString(),
386
- end: resolvedSpendPermission.end.toString(),
387
- salt: resolvedSpendPermission.salt.toString(),
388
- extraData: resolvedSpendPermission.extraData,
389
- network: options.network,
390
- paymasterUrl: options.paymasterUrl,
391
- },
392
- options.idempotencyKey,
393
- );
405
+ const userOperation = await CdpOpenApiClient.createSpendPermission(
406
+ resolvedSpendPermission.account,
407
+ {
408
+ spender: resolvedSpendPermission.spender,
409
+ token: resolvedSpendPermission.token,
410
+ allowance: resolvedSpendPermission.allowance.toString(),
411
+ period: resolvedSpendPermission.period.toString(),
412
+ start: resolvedSpendPermission.start.toString(),
413
+ end: resolvedSpendPermission.end.toString(),
414
+ salt: resolvedSpendPermission.salt.toString(),
415
+ extraData: resolvedSpendPermission.extraData,
416
+ network: options.network,
417
+ paymasterUrl: options.paymasterUrl,
418
+ },
419
+ options.idempotencyKey,
420
+ );
394
421
 
395
- return {
396
- network: userOperation.network,
397
- userOpHash: userOperation.userOpHash as Hex,
398
- status: userOperation.status,
399
- calls: userOperation.calls.map(call => ({
400
- to: call.to as Address,
401
- value: BigInt(call.value),
402
- data: call.data as Hex,
403
- })),
404
- };
422
+ return {
423
+ network: userOperation.network,
424
+ userOpHash: userOperation.userOpHash as Hex,
425
+ status: userOperation.status,
426
+ calls: userOperation.calls.map(call => ({
427
+ to: call.to as Address,
428
+ value: BigInt(call.value),
429
+ data: call.data as Hex,
430
+ })),
431
+ };
432
+ } catch (error) {
433
+ Analytics.trackError(error, "createSpendPermission");
434
+ throw error;
435
+ }
405
436
  }
406
437
 
407
438
  /**
@@ -429,26 +460,31 @@ export class EvmClient implements EvmClientInterface {
429
460
  action: "revoke_spend_permission",
430
461
  });
431
462
 
432
- const userOperation = await CdpOpenApiClient.revokeSpendPermission(
433
- options.address,
434
- {
435
- network: options.network,
436
- permissionHash: options.permissionHash,
437
- paymasterUrl: options.paymasterUrl,
438
- },
439
- options.idempotencyKey,
440
- );
463
+ try {
464
+ const userOperation = await CdpOpenApiClient.revokeSpendPermission(
465
+ options.address,
466
+ {
467
+ network: options.network,
468
+ permissionHash: options.permissionHash,
469
+ paymasterUrl: options.paymasterUrl,
470
+ },
471
+ options.idempotencyKey,
472
+ );
441
473
 
442
- return {
443
- network: userOperation.network,
444
- userOpHash: userOperation.userOpHash as Hex,
445
- status: userOperation.status,
446
- calls: userOperation.calls.map(call => ({
447
- to: call.to as Address,
448
- value: BigInt(call.value),
449
- data: call.data as Hex,
450
- })),
451
- };
474
+ return {
475
+ network: userOperation.network,
476
+ userOpHash: userOperation.userOpHash as Hex,
477
+ status: userOperation.status,
478
+ calls: userOperation.calls.map(call => ({
479
+ to: call.to as Address,
480
+ value: BigInt(call.value),
481
+ data: call.data as Hex,
482
+ })),
483
+ };
484
+ } catch (error) {
485
+ Analytics.trackError(error, "revokeSpendPermission");
486
+ throw error;
487
+ }
452
488
  }
453
489
 
454
490
  /**
@@ -482,7 +518,12 @@ export class EvmClient implements EvmClientInterface {
482
518
  accountType: "evm_server",
483
519
  });
484
520
 
485
- return this._getAccountInternal(options);
521
+ try {
522
+ return await this._getAccountInternal(options);
523
+ } catch (error) {
524
+ Analytics.trackError(error, "getAccount");
525
+ throw error;
526
+ }
486
527
  }
487
528
 
488
529
  /**
@@ -512,7 +553,12 @@ export class EvmClient implements EvmClientInterface {
512
553
  action: "get_smart_account",
513
554
  });
514
555
 
515
- return this._getSmartAccountInternal(options);
556
+ try {
557
+ return await this._getSmartAccountInternal(options);
558
+ } catch (error) {
559
+ Analytics.trackError(error, "getSmartAccount");
560
+ throw error;
561
+ }
516
562
  }
517
563
 
518
564
  /**
@@ -537,25 +583,30 @@ export class EvmClient implements EvmClientInterface {
537
583
  });
538
584
 
539
585
  try {
540
- const account = await this._getAccountInternal(options);
541
- return account;
542
- } catch (error) {
543
- // If it failed because the account doesn't exist, create it
544
- const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
545
- if (doesAccountNotExist) {
546
- try {
547
- const account = await this._createAccountInternal(options);
548
- return account;
549
- } catch (error) {
550
- // If it failed because the account already exists, get the existing account
551
- const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
552
- if (doesAccountAlreadyExist) {
553
- const account = await this._getAccountInternal(options);
586
+ try {
587
+ const account = await this._getAccountInternal(options);
588
+ return account;
589
+ } catch (error) {
590
+ // If it failed because the account doesn't exist, create it
591
+ const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
592
+ if (doesAccountNotExist) {
593
+ try {
594
+ const account = await this._createAccountInternal(options);
554
595
  return account;
596
+ } catch (error) {
597
+ // If it failed because the account already exists, get the existing account
598
+ const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
599
+ if (doesAccountAlreadyExist) {
600
+ const account = await this._getAccountInternal(options);
601
+ return account;
602
+ }
603
+ throw error;
555
604
  }
556
- throw error;
557
605
  }
606
+ throw error;
558
607
  }
608
+ } catch (error) {
609
+ Analytics.trackError(error, "getOrCreateAccount");
559
610
  throw error;
560
611
  }
561
612
  }
@@ -586,25 +637,30 @@ export class EvmClient implements EvmClientInterface {
586
637
  });
587
638
 
588
639
  try {
589
- const account = await this._getSmartAccountInternal(options);
590
- return account;
591
- } catch (error) {
592
- // If it failed because the account doesn't exist, create it
593
- const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
594
- if (doesAccountNotExist) {
595
- try {
596
- const account = await this._createSmartAccountInternal(options);
597
- return account;
598
- } catch (error) {
599
- // If it failed because the account already exists, get the existing account
600
- const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
601
- if (doesAccountAlreadyExist) {
602
- const account = await this._getSmartAccountInternal(options);
640
+ try {
641
+ const account = await this._getSmartAccountInternal(options);
642
+ return account;
643
+ } catch (error) {
644
+ // If it failed because the account doesn't exist, create it
645
+ const doesAccountNotExist = error instanceof APIError && error.statusCode === 404;
646
+ if (doesAccountNotExist) {
647
+ try {
648
+ const account = await this._createSmartAccountInternal(options);
603
649
  return account;
650
+ } catch (error) {
651
+ // If it failed because the account already exists, get the existing account
652
+ const doesAccountAlreadyExist = error instanceof APIError && error.statusCode === 409;
653
+ if (doesAccountAlreadyExist) {
654
+ const account = await this._getSmartAccountInternal(options);
655
+ return account;
656
+ }
657
+ throw error;
604
658
  }
605
- throw error;
606
659
  }
660
+ throw error;
607
661
  }
662
+ } catch (error) {
663
+ Analytics.trackError(error, "getOrCreateSmartAccount");
608
664
  throw error;
609
665
  }
610
666
  }
@@ -637,7 +693,12 @@ export class EvmClient implements EvmClientInterface {
637
693
  },
638
694
  });
639
695
 
640
- return getSwapPrice(CdpOpenApiClient, options);
696
+ try {
697
+ return await getSwapPrice(CdpOpenApiClient, options);
698
+ } catch (error) {
699
+ Analytics.trackError(error, "getSwapPrice");
700
+ throw error;
701
+ }
641
702
  }
642
703
 
643
704
  /**
@@ -668,7 +729,12 @@ export class EvmClient implements EvmClientInterface {
668
729
  },
669
730
  });
670
731
 
671
- return createSwapQuote(CdpOpenApiClient, options);
732
+ try {
733
+ return await createSwapQuote(CdpOpenApiClient, options);
734
+ } catch (error) {
735
+ Analytics.trackError(error, "createSwapQuote");
736
+ throw error;
737
+ }
672
738
  }
673
739
 
674
740
  /**
@@ -693,7 +759,12 @@ export class EvmClient implements EvmClientInterface {
693
759
  action: "get_user_operation",
694
760
  });
695
761
 
696
- return getUserOperation(CdpOpenApiClient, options);
762
+ try {
763
+ return await getUserOperation(CdpOpenApiClient, options);
764
+ } catch (error) {
765
+ Analytics.trackError(error, "getUserOperation");
766
+ throw error;
767
+ }
697
768
  }
698
769
 
699
770
  /**
@@ -726,23 +797,26 @@ export class EvmClient implements EvmClientInterface {
726
797
  accountType: "evm_server",
727
798
  });
728
799
 
729
- const ethAccounts = await CdpOpenApiClient.listEvmAccounts({
730
- pageSize: options.pageSize,
731
- pageToken: options.pageToken,
732
- });
733
-
734
- return {
735
- accounts: ethAccounts.accounts.map(account => {
736
- const evmAccount = toEvmServerAccount(CdpOpenApiClient, {
737
- account,
738
- });
800
+ try {
801
+ const ethAccounts = await CdpOpenApiClient.listEvmAccounts({
802
+ pageSize: options.pageSize,
803
+ pageToken: options.pageToken,
804
+ });
739
805
 
740
- Analytics.wrapObjectMethodsWithErrorTracking(evmAccount);
806
+ return {
807
+ accounts: ethAccounts.accounts.map(account => {
808
+ const evmAccount = toEvmServerAccount(CdpOpenApiClient, {
809
+ account,
810
+ });
741
811
 
742
- return evmAccount;
743
- }),
744
- nextPageToken: ethAccounts.nextPageToken,
745
- };
812
+ return evmAccount;
813
+ }),
814
+ nextPageToken: ethAccounts.nextPageToken,
815
+ };
816
+ } catch (error) {
817
+ Analytics.trackError(error, "listAccounts");
818
+ throw error;
819
+ }
746
820
  }
747
821
 
748
822
  /**
@@ -787,7 +861,12 @@ export class EvmClient implements EvmClientInterface {
787
861
  },
788
862
  });
789
863
 
790
- return listTokenBalances(CdpOpenApiClient, options);
864
+ try {
865
+ return await listTokenBalances(CdpOpenApiClient, options);
866
+ } catch (error) {
867
+ Analytics.trackError(error, "listTokenBalances");
868
+ throw error;
869
+ }
791
870
  }
792
871
 
793
872
  /**
@@ -819,20 +898,25 @@ export class EvmClient implements EvmClientInterface {
819
898
  action: "list_smart_accounts",
820
899
  });
821
900
 
822
- const smartAccounts = await CdpOpenApiClient.listEvmSmartAccounts({
823
- pageSize: options.pageSize,
824
- pageToken: options.pageToken,
825
- });
901
+ try {
902
+ const smartAccounts = await CdpOpenApiClient.listEvmSmartAccounts({
903
+ pageSize: options.pageSize,
904
+ pageToken: options.pageToken,
905
+ });
826
906
 
827
- return {
828
- accounts: smartAccounts.accounts.map(account => ({
829
- address: account.address as Address,
830
- owners: [account.owners[0] as Address],
831
- type: "evm-smart",
832
- policies: account.policies,
833
- })),
834
- nextPageToken: smartAccounts.nextPageToken,
835
- };
907
+ return {
908
+ accounts: smartAccounts.accounts.map(account => ({
909
+ address: account.address as Address,
910
+ owners: [account.owners[0] as Address],
911
+ type: "evm-smart",
912
+ policies: account.policies,
913
+ })),
914
+ nextPageToken: smartAccounts.nextPageToken,
915
+ };
916
+ } catch (error) {
917
+ Analytics.trackError(error, "listSmartAccounts");
918
+ throw error;
919
+ }
836
920
  }
837
921
 
838
922
  /**
@@ -852,7 +936,12 @@ export class EvmClient implements EvmClientInterface {
852
936
  action: "list_spend_permissions",
853
937
  });
854
938
 
855
- return listSpendPermissions(CdpOpenApiClient, options);
939
+ try {
940
+ return await listSpendPermissions(CdpOpenApiClient, options);
941
+ } catch (error) {
942
+ Analytics.trackError(error, "listSpendPermissions");
943
+ throw error;
944
+ }
856
945
  }
857
946
 
858
947
  /**
@@ -889,28 +978,33 @@ export class EvmClient implements EvmClientInterface {
889
978
  },
890
979
  });
891
980
 
892
- const userOp = await CdpOpenApiClient.prepareUserOperation(options.smartAccount.address, {
893
- network: options.network,
894
- calls: options.calls.map(call => ({
895
- to: call.to as Address,
896
- value: call.value.toString(),
897
- data: call.data as Hex,
898
- overrideGasLimit: call.overrideGasLimit,
899
- })),
900
- paymasterUrl: options.paymasterUrl,
901
- dataSuffix: options.dataSuffix,
902
- });
981
+ try {
982
+ const userOp = await CdpOpenApiClient.prepareUserOperation(options.smartAccount.address, {
983
+ network: options.network,
984
+ calls: options.calls.map(call => ({
985
+ to: call.to as Address,
986
+ value: call.value.toString(),
987
+ data: call.data as Hex,
988
+ overrideGasLimit: call.overrideGasLimit,
989
+ })),
990
+ paymasterUrl: options.paymasterUrl,
991
+ dataSuffix: options.dataSuffix,
992
+ });
903
993
 
904
- return {
905
- network: userOp.network,
906
- userOpHash: userOp.userOpHash as Hex,
907
- status: userOp.status,
908
- calls: userOp.calls.map(call => ({
909
- to: call.to as Address,
910
- value: BigInt(call.value),
911
- data: call.data as Hex,
912
- })),
913
- };
994
+ return {
995
+ network: userOp.network,
996
+ userOpHash: userOp.userOpHash as Hex,
997
+ status: userOp.status,
998
+ calls: userOp.calls.map(call => ({
999
+ to: call.to as Address,
1000
+ value: BigInt(call.value),
1001
+ data: call.data as Hex,
1002
+ })),
1003
+ };
1004
+ } catch (error) {
1005
+ Analytics.trackError(error, "prepareUserOperation");
1006
+ throw error;
1007
+ }
914
1008
  }
915
1009
 
916
1010
  /**
@@ -949,25 +1043,30 @@ export class EvmClient implements EvmClientInterface {
949
1043
  },
950
1044
  });
951
1045
 
952
- const userOp = await CdpOpenApiClient.prepareAndSendUserOperation(
953
- options.smartAccount.address,
954
- {
955
- network: options.network,
956
- calls: options.calls.map(call => ({
957
- to: call.to as Address,
958
- value: call.value.toString(),
959
- data: call.data as Hex,
960
- })),
961
- paymasterUrl: options.paymasterUrl,
962
- },
963
- options.idempotencyKey,
964
- );
1046
+ try {
1047
+ const userOp = await CdpOpenApiClient.prepareAndSendUserOperation(
1048
+ options.smartAccount.address,
1049
+ {
1050
+ network: options.network,
1051
+ calls: options.calls.map(call => ({
1052
+ to: call.to as Address,
1053
+ value: call.value.toString(),
1054
+ data: call.data as Hex,
1055
+ })),
1056
+ paymasterUrl: options.paymasterUrl,
1057
+ },
1058
+ options.idempotencyKey,
1059
+ );
965
1060
 
966
- return {
967
- smartAccountAddress: options.smartAccount.address as Address,
968
- userOpHash: userOp.userOpHash as Hex,
969
- status: userOp.status as typeof EvmUserOperationStatus.broadcast,
970
- };
1061
+ return {
1062
+ smartAccountAddress: options.smartAccount.address as Address,
1063
+ userOpHash: userOp.userOpHash as Hex,
1064
+ status: userOp.status as typeof EvmUserOperationStatus.broadcast,
1065
+ };
1066
+ } catch (error) {
1067
+ Analytics.trackError(error, "prepareAndSendUserOperation");
1068
+ throw error;
1069
+ }
971
1070
  }
972
1071
 
973
1072
  /**
@@ -998,7 +1097,12 @@ export class EvmClient implements EvmClientInterface {
998
1097
  },
999
1098
  });
1000
1099
 
1001
- return requestFaucet(CdpOpenApiClient, options);
1100
+ try {
1101
+ return await requestFaucet(CdpOpenApiClient, options);
1102
+ } catch (error) {
1103
+ Analytics.trackError(error, "requestFaucet");
1104
+ throw error;
1105
+ }
1002
1106
  }
1003
1107
 
1004
1108
  /**
@@ -1055,7 +1159,12 @@ export class EvmClient implements EvmClientInterface {
1055
1159
  },
1056
1160
  });
1057
1161
 
1058
- return sendTransaction(CdpOpenApiClient, options);
1162
+ try {
1163
+ return await sendTransaction(CdpOpenApiClient, options);
1164
+ } catch (error) {
1165
+ Analytics.trackError(error, "sendTransaction");
1166
+ throw error;
1167
+ }
1059
1168
  }
1060
1169
 
1061
1170
  /**
@@ -1096,14 +1205,19 @@ export class EvmClient implements EvmClientInterface {
1096
1205
  },
1097
1206
  });
1098
1207
 
1099
- return sendUserOperation(CdpOpenApiClient, {
1100
- smartAccount: options.smartAccount,
1101
- network: options.network,
1102
- calls: options.calls,
1103
- paymasterUrl: options.paymasterUrl,
1104
- idempotencyKey: options.idempotencyKey,
1105
- dataSuffix: options.dataSuffix,
1106
- });
1208
+ try {
1209
+ return await sendUserOperation(CdpOpenApiClient, {
1210
+ smartAccount: options.smartAccount,
1211
+ network: options.network,
1212
+ calls: options.calls,
1213
+ paymasterUrl: options.paymasterUrl,
1214
+ idempotencyKey: options.idempotencyKey,
1215
+ dataSuffix: options.dataSuffix,
1216
+ });
1217
+ } catch (error) {
1218
+ Analytics.trackError(error, "sendUserOperation");
1219
+ throw error;
1220
+ }
1107
1221
  }
1108
1222
 
1109
1223
  /**
@@ -1132,17 +1246,22 @@ export class EvmClient implements EvmClientInterface {
1132
1246
  action: "sign_hash",
1133
1247
  });
1134
1248
 
1135
- const signature = await CdpOpenApiClient.signEvmHash(
1136
- options.address,
1137
- {
1138
- hash: options.hash,
1139
- },
1140
- options.idempotencyKey,
1141
- );
1249
+ try {
1250
+ const signature = await CdpOpenApiClient.signEvmHash(
1251
+ options.address,
1252
+ {
1253
+ hash: options.hash,
1254
+ },
1255
+ options.idempotencyKey,
1256
+ );
1142
1257
 
1143
- return {
1144
- signature: signature.signature as Hex,
1145
- };
1258
+ return {
1259
+ signature: signature.signature as Hex,
1260
+ };
1261
+ } catch (error) {
1262
+ Analytics.trackError(error, "signHash");
1263
+ throw error;
1264
+ }
1146
1265
  }
1147
1266
 
1148
1267
  /**
@@ -1171,17 +1290,22 @@ export class EvmClient implements EvmClientInterface {
1171
1290
  action: "sign_message",
1172
1291
  });
1173
1292
 
1174
- const signature = await CdpOpenApiClient.signEvmMessage(
1175
- options.address,
1176
- {
1177
- message: options.message,
1178
- },
1179
- options.idempotencyKey,
1180
- );
1293
+ try {
1294
+ const signature = await CdpOpenApiClient.signEvmMessage(
1295
+ options.address,
1296
+ {
1297
+ message: options.message,
1298
+ },
1299
+ options.idempotencyKey,
1300
+ );
1181
1301
 
1182
- return {
1183
- signature: signature.signature as Hex,
1184
- };
1302
+ return {
1303
+ signature: signature.signature as Hex,
1304
+ };
1305
+ } catch (error) {
1306
+ Analytics.trackError(error, "signMessage");
1307
+ throw error;
1308
+ }
1185
1309
  }
1186
1310
 
1187
1311
  /**
@@ -1234,28 +1358,33 @@ export class EvmClient implements EvmClientInterface {
1234
1358
  action: "sign_typed_data",
1235
1359
  });
1236
1360
 
1237
- const { domain, message, primaryType } = options;
1238
- const types = {
1239
- EIP712Domain: getTypesForEIP712Domain({ domain }),
1240
- ...options.types,
1241
- };
1242
-
1243
- const openApiMessage: OpenAPIEIP712Message = {
1244
- domain,
1245
- types,
1246
- primaryType,
1247
- message,
1248
- };
1249
-
1250
- const signature = await CdpOpenApiClient.signEvmTypedData(
1251
- options.address,
1252
- openApiMessage,
1253
- options.idempotencyKey,
1254
- );
1361
+ try {
1362
+ const { domain, message, primaryType } = options;
1363
+ const types = {
1364
+ EIP712Domain: getTypesForEIP712Domain({ domain }),
1365
+ ...options.types,
1366
+ };
1367
+
1368
+ const openApiMessage: OpenAPIEIP712Message = {
1369
+ domain,
1370
+ types,
1371
+ primaryType,
1372
+ message,
1373
+ };
1374
+
1375
+ const signature = await CdpOpenApiClient.signEvmTypedData(
1376
+ options.address,
1377
+ openApiMessage,
1378
+ options.idempotencyKey,
1379
+ );
1255
1380
 
1256
- return {
1257
- signature: signature.signature as Hex,
1258
- };
1381
+ return {
1382
+ signature: signature.signature as Hex,
1383
+ };
1384
+ } catch (error) {
1385
+ Analytics.trackError(error, "signTypedData");
1386
+ throw error;
1387
+ }
1259
1388
  }
1260
1389
 
1261
1390
  /**
@@ -1293,17 +1422,22 @@ export class EvmClient implements EvmClientInterface {
1293
1422
  action: "sign_transaction",
1294
1423
  });
1295
1424
 
1296
- const signature = await CdpOpenApiClient.signEvmTransaction(
1297
- options.address,
1298
- {
1299
- transaction: options.transaction,
1300
- },
1301
- options.idempotencyKey,
1302
- );
1425
+ try {
1426
+ const signature = await CdpOpenApiClient.signEvmTransaction(
1427
+ options.address,
1428
+ {
1429
+ transaction: options.transaction,
1430
+ },
1431
+ options.idempotencyKey,
1432
+ );
1303
1433
 
1304
- return {
1305
- signature: signature.signedTransaction as Hex,
1306
- };
1434
+ return {
1435
+ signature: signature.signedTransaction as Hex,
1436
+ };
1437
+ } catch (error) {
1438
+ Analytics.trackError(error, "signTransaction");
1439
+ throw error;
1440
+ }
1307
1441
  }
1308
1442
 
1309
1443
  /**
@@ -1352,19 +1486,22 @@ export class EvmClient implements EvmClientInterface {
1352
1486
  action: "update_account",
1353
1487
  });
1354
1488
 
1355
- const openApiAccount = await CdpOpenApiClient.updateEvmAccount(
1356
- options.address,
1357
- options.update,
1358
- options.idempotencyKey,
1359
- );
1360
-
1361
- const account = toEvmServerAccount(CdpOpenApiClient, {
1362
- account: openApiAccount,
1363
- });
1489
+ try {
1490
+ const openApiAccount = await CdpOpenApiClient.updateEvmAccount(
1491
+ options.address,
1492
+ options.update,
1493
+ options.idempotencyKey,
1494
+ );
1364
1495
 
1365
- Analytics.wrapObjectMethodsWithErrorTracking(account);
1496
+ const account = toEvmServerAccount(CdpOpenApiClient, {
1497
+ account: openApiAccount,
1498
+ });
1366
1499
 
1367
- return account;
1500
+ return account;
1501
+ } catch (error) {
1502
+ Analytics.trackError(error, "updateAccount");
1503
+ throw error;
1504
+ }
1368
1505
  }
1369
1506
 
1370
1507
  /**
@@ -1384,20 +1521,121 @@ export class EvmClient implements EvmClientInterface {
1384
1521
  action: "update_smart_account",
1385
1522
  });
1386
1523
 
1387
- const openApiSmartAccount = await CdpOpenApiClient.updateEvmSmartAccount(
1388
- options.address,
1389
- options.update,
1390
- options.idempotencyKey,
1391
- );
1524
+ try {
1525
+ const openApiSmartAccount = await CdpOpenApiClient.updateEvmSmartAccount(
1526
+ options.address,
1527
+ options.update,
1528
+ options.idempotencyKey,
1529
+ );
1392
1530
 
1393
- const smartAccount = toEvmSmartAccount(CdpOpenApiClient, {
1394
- smartAccount: openApiSmartAccount,
1395
- owner: options.owner,
1531
+ const smartAccount = toEvmSmartAccount(CdpOpenApiClient, {
1532
+ smartAccount: openApiSmartAccount,
1533
+ owner: options.owner,
1534
+ });
1535
+
1536
+ return smartAccount;
1537
+ } catch (error) {
1538
+ Analytics.trackError(error, "updateSmartAccount");
1539
+ throw error;
1540
+ }
1541
+ }
1542
+
1543
+ /**
1544
+ * Creates an EIP-7702 delegation for an EVM EOA account, upgrading it with smart account capabilities.
1545
+ * The delegation allows the EVM EOA to be used as a smart account, which enables batched transactions and gas sponsorship via paymaster.
1546
+ *
1547
+ * @param {CreateEvmEip7702DelegationOptions} options - The delegation parameters (address and network required, enableSpendPermissions and idempotencyKey optional).
1548
+ * @returns A promise that resolves to the delegation result including the delegation operation ID.
1549
+ *
1550
+ * @example
1551
+ * ```ts
1552
+ * const result = await cdp.evm.createEvmEip7702Delegation({
1553
+ * address: account.address,
1554
+ * network: "base-sepolia",
1555
+ * enableSpendPermissions: false,
1556
+ * });
1557
+ * console.log(result.delegationOperationId);
1558
+ * ```
1559
+ */
1560
+ async createEvmEip7702Delegation(
1561
+ options: CreateEvmEip7702DelegationOptions,
1562
+ ): Promise<CreateEvmEip7702DelegationResult> {
1563
+ Analytics.trackAction({
1564
+ action: "create_eip7702_delegation",
1396
1565
  });
1397
1566
 
1398
- Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
1567
+ try {
1568
+ const { address, network, enableSpendPermissions, idempotencyKey } = options;
1569
+ const body = {
1570
+ network,
1571
+ ...(enableSpendPermissions !== undefined && { enableSpendPermissions }),
1572
+ };
1573
+ return await CdpOpenApiClient.createEvmEip7702Delegation(address, body, idempotencyKey);
1574
+ } catch (error) {
1575
+ Analytics.trackError(error, "createEvmEip7702Delegation");
1576
+ throw error;
1577
+ }
1578
+ }
1399
1579
 
1400
- return smartAccount;
1580
+ /**
1581
+ * Gets the EIP-7702 delegation operation status.
1582
+ *
1583
+ * @param {string} delegationOperationId - The delegation operation ID returned by createEvmEip7702Delegation.
1584
+ * @returns A promise that resolves to the delegation operation status.
1585
+ *
1586
+ * @example
1587
+ * ```ts
1588
+ * const operation = await cdp.evm.getEvmEip7702DelegationOperationById(
1589
+ * "delegation-op-123",
1590
+ * );
1591
+ * console.log(operation.status); // "PENDING" | "SUBMITTED" | "COMPLETED" | "FAILED"
1592
+ * ```
1593
+ */
1594
+ async getEvmEip7702DelegationOperationById(
1595
+ delegationOperationId: string,
1596
+ ): Promise<EvmEip7702DelegationOperation> {
1597
+ Analytics.trackAction({
1598
+ action: "get_eip7702_delegation_operation_by_id",
1599
+ });
1600
+
1601
+ try {
1602
+ return await CdpOpenApiClient.getEvmEip7702DelegationOperationById(delegationOperationId);
1603
+ } catch (error) {
1604
+ Analytics.trackError(error, "getEvmEip7702DelegationOperationById");
1605
+ throw error;
1606
+ }
1607
+ }
1608
+
1609
+ /**
1610
+ * Polls the EIP-7702 delegation operation status until the status is COMPLETED or a timeout occurs.
1611
+ *
1612
+ * @param {WaitForEvmEip7702DelegationOperationStatusOptions} options - Parameters for waiting, including delegationOperationId and optional wait configuration.
1613
+ * @param {string} options.delegationOperationId - The delegation operation ID returned by createEvmEip7702Delegation.
1614
+ * @param {WaitOptions} [options.waitOptions] - Optional parameters for the wait operation.
1615
+ *
1616
+ * @returns A promise that resolves to the delegation operation once it reaches COMPLETED.
1617
+ *
1618
+ * @example
1619
+ * ```ts
1620
+ * const operation = await cdp.evm.waitForEvmEip7702DelegationOperationStatus({
1621
+ * delegationOperationId: "delegation-op-123",
1622
+ * });
1623
+ * console.log(operation.status); // "COMPLETED"
1624
+ * ```
1625
+ */
1626
+ async waitForEvmEip7702DelegationOperationStatus(
1627
+ options: WaitForEvmEip7702DelegationOperationStatusOptions,
1628
+ ): Promise<EvmEip7702DelegationOperation> {
1629
+ Analytics.trackAction({
1630
+ action: "wait_for_eip7702_delegation_operation_status",
1631
+ });
1632
+
1633
+ try {
1634
+ return await waitForEvmEip7702DelegationOperationStatus(CdpOpenApiClient, options);
1635
+ } catch (error) {
1636
+ Analytics.trackError(error, "waitForEvmEip7702DelegationOperationStatus");
1637
+ throw error;
1638
+ }
1401
1639
  }
1402
1640
 
1403
1641
  /**
@@ -1439,9 +1677,14 @@ export class EvmClient implements EvmClientInterface {
1439
1677
  action: "wait_for_user_operation",
1440
1678
  });
1441
1679
 
1442
- return waitForUserOperation(CdpOpenApiClient, {
1443
- ...options,
1444
- });
1680
+ try {
1681
+ return await waitForUserOperation(CdpOpenApiClient, {
1682
+ ...options,
1683
+ });
1684
+ } catch (error) {
1685
+ Analytics.trackError(error, "waitForUserOperation");
1686
+ throw error;
1687
+ }
1445
1688
  }
1446
1689
 
1447
1690
  /**
@@ -1466,8 +1709,6 @@ export class EvmClient implements EvmClientInterface {
1466
1709
  account: openApiAccount,
1467
1710
  });
1468
1711
 
1469
- Analytics.wrapObjectMethodsWithErrorTracking(account);
1470
-
1471
1712
  return account;
1472
1713
  }
1473
1714
 
@@ -1495,8 +1736,6 @@ export class EvmClient implements EvmClientInterface {
1495
1736
  account: openApiAccount,
1496
1737
  });
1497
1738
 
1498
- Analytics.wrapObjectMethodsWithErrorTracking(account);
1499
-
1500
1739
  return account;
1501
1740
  }
1502
1741
 
@@ -1529,8 +1768,6 @@ export class EvmClient implements EvmClientInterface {
1529
1768
  owner: options.owner,
1530
1769
  });
1531
1770
 
1532
- Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
1533
-
1534
1771
  return smartAccount;
1535
1772
  }
1536
1773
 
@@ -1566,8 +1803,6 @@ Provided Owner Address: ${options.owner.address}\n`,
1566
1803
  owner: options.owner,
1567
1804
  });
1568
1805
 
1569
- Analytics.wrapObjectMethodsWithErrorTracking(smartAccount);
1570
-
1571
1806
  return smartAccount;
1572
1807
  }
1573
1808
  }