@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
@@ -75,18 +75,44 @@ export type AccountActions = {
75
75
  * // Create a Solana account
76
76
  * const account = await cdp.solana.createAccount();
77
77
  *
78
- * // Add your transaction instructions here
79
- * const transaction = new Transaction()
80
- *
81
- * // Make sure to set requireAllSignatures to false, since signing will be done through the API
82
- * const serializedTransaction = transaction.serialize({
83
- * requireAllSignatures: false,
84
- * });
85
- *
86
- * // Base64 encode the serialized transaction
87
- * const transaction = Buffer.from(serializedTransaction).toString("base64");
88
- *
89
- * // When you want to sign a transaction, you can do so by address and base64 encoded transaction
78
+ * // Build your transaction using @solana/kit
79
+ * import {
80
+ * address as solanaAddress,
81
+ * appendTransactionMessageInstructions,
82
+ * compileTransaction,
83
+ * createNoopSigner,
84
+ * createSolanaRpc,
85
+ * createTransactionMessage,
86
+ * getBase64EncodedWireTransaction,
87
+ * pipe,
88
+ * setTransactionMessageFeePayer,
89
+ * setTransactionMessageLifetimeUsingBlockhash,
90
+ * } from "@solana/kit";
91
+ * import { getTransferSolInstruction } from "@solana-program/system";
92
+ *
93
+ * const rpc = createSolanaRpc("https://api.devnet.solana.com");
94
+ * const { value: { blockhash, lastValidBlockHeight } } = await rpc.getLatestBlockhash().send();
95
+ *
96
+ * const txMsg = pipe(
97
+ * createTransactionMessage({ version: 0 }),
98
+ * (tx) => setTransactionMessageFeePayer(solanaAddress(account.address), tx),
99
+ * (tx) => setTransactionMessageLifetimeUsingBlockhash(
100
+ * { blockhash, lastValidBlockHeight },
101
+ * tx,
102
+ * ),
103
+ * (tx) => appendTransactionMessageInstructions([
104
+ * getTransferSolInstruction({
105
+ * source: createNoopSigner(solanaAddress(account.address)),
106
+ * destination: solanaAddress("3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE"),
107
+ * amount: 10000n,
108
+ * }),
109
+ * ], tx),
110
+ * );
111
+ *
112
+ * // Base64 encode the compiled transaction
113
+ * const transaction = getBase64EncodedWireTransaction(compileTransaction(txMsg));
114
+ *
115
+ * // Sign the transaction via the CDP API
90
116
  * const { signedTransaction } = await account.signTransaction({
91
117
  * transaction,
92
118
  * });
@@ -111,18 +137,44 @@ export type AccountActions = {
111
137
  * // Create a Solana account
112
138
  * const account = await cdp.solana.createAccount();
113
139
  *
114
- * // Add your transaction instructions here
115
- * const transaction = new Transaction()
116
- *
117
- * // Make sure to set requireAllSignatures to false, since signing will be done through the API
118
- * const serializedTransaction = transaction.serialize({
119
- * requireAllSignatures: false,
120
- * });
121
- *
122
- * // Base64 encode the serialized transaction
123
- * const transaction = Buffer.from(serializedTransaction).toString("base64");
124
- *
125
- * // When you want to sign a transaction, you can do so by address and base64 encoded transaction
140
+ * // Build your transaction using @solana/kit
141
+ * import {
142
+ * address as solanaAddress,
143
+ * appendTransactionMessageInstructions,
144
+ * compileTransaction,
145
+ * createNoopSigner,
146
+ * createSolanaRpc,
147
+ * createTransactionMessage,
148
+ * getBase64EncodedWireTransaction,
149
+ * pipe,
150
+ * setTransactionMessageFeePayer,
151
+ * setTransactionMessageLifetimeUsingBlockhash,
152
+ * } from "@solana/kit";
153
+ * import { getTransferSolInstruction } from "@solana-program/system";
154
+ *
155
+ * const rpc = createSolanaRpc("https://api.devnet.solana.com");
156
+ * const { value: { blockhash, lastValidBlockHeight } } = await rpc.getLatestBlockhash().send();
157
+ *
158
+ * const txMsg = pipe(
159
+ * createTransactionMessage({ version: 0 }),
160
+ * (tx) => setTransactionMessageFeePayer(solanaAddress(account.address), tx),
161
+ * (tx) => setTransactionMessageLifetimeUsingBlockhash(
162
+ * { blockhash, lastValidBlockHeight },
163
+ * tx,
164
+ * ),
165
+ * (tx) => appendTransactionMessageInstructions([
166
+ * getTransferSolInstruction({
167
+ * source: createNoopSigner(solanaAddress(account.address)),
168
+ * destination: solanaAddress("3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE"),
169
+ * amount: 10000n,
170
+ * }),
171
+ * ], tx),
172
+ * );
173
+ *
174
+ * // Base64 encode the compiled transaction
175
+ * const transaction = getBase64EncodedWireTransaction(compileTransaction(txMsg));
176
+ *
177
+ * // Send the transaction via the CDP API
126
178
  * const { transactionSignature } = await account.sendTransaction({
127
179
  * transaction,
128
180
  * });
@@ -138,20 +190,18 @@ export type AccountActions = {
138
190
  * @param {TransferOptions} options - Parameters for the transfer.
139
191
  * @param {string} options.to - The base58 encoded Solana address of the destination account.
140
192
  * @param {sol|usdc|string} options.token - The token to transfer ("sol" or "usdc"), or mint address of the SPL token to transfer.
141
- * @param {bigint} options.amount - The amount to transfer in atomic units of the token. For example, 0.01 * LAMPORTS_PER_SOL would transfer 0.01 SOL.
142
- * @param {string | Connection} options.network - The network identifier to use, or a Solana Connection object.
193
+ * @param {bigint} options.amount - The amount to transfer in atomic units of the token. For example, 1 SOL = 1_000_000_000 lamports.
194
+ * @param {string | SolanaRpcClient} options.network - The network identifier ("mainnet" or "devnet") to use, or an existing Solana RPC client.
143
195
  *
144
196
  * @returns A promise that resolves to the transaction signature, which can be used to wait for the transaction result.
145
197
  *
146
198
  * @example
147
199
  * ```ts
148
- * import { LAMPORTS_PER_SOL } from "@solana/web3.js";
149
- *
150
200
  * const account = await cdp.solana.getAccount({ name: "Account" });
151
201
  *
152
202
  * const { signature } = await account.transfer({
153
203
  * token: "sol",
154
- * amount: 5 * LAMPORTS_PER_SOL,
204
+ * amount: 5_000_000_000n, // 5 SOL in lamports
155
205
  * to: "3KzDtddx4i53FBkvCzuDmRbaMozTZoJBb1TToWhz3JfE",
156
206
  * network: "devnet",
157
207
  * });
@@ -1,4 +1,4 @@
1
- import { Connection } from "@solana/web3.js";
1
+ import { createSolanaRpc } from "@solana/kit";
2
2
 
3
3
  import {
4
4
  GENESIS_HASH_MAINNET,
@@ -9,27 +9,29 @@ import {
9
9
 
10
10
  export type Network = "mainnet" | "devnet";
11
11
 
12
+ export type SolanaRpcClient = ReturnType<typeof createSolanaRpc>;
13
+
12
14
  type GetOrCreateConnectionOptions = {
13
- networkOrConnection: Network | Connection;
15
+ networkOrConnection: Network | SolanaRpcClient;
14
16
  };
15
17
 
16
18
  /**
17
- * Get a connection for the Solana network
19
+ * Get a Solana RPC client for the given network or return the provided one
18
20
  *
19
21
  * @param options - The options for the connection
20
22
  *
21
- * @param options.networkOrConnection - The network to use or a connection
23
+ * @param options.networkOrConnection - The network to use or an existing RPC client
22
24
  *
23
- * @returns The connection
25
+ * @returns The RPC client
24
26
  */
25
27
  export function getOrCreateConnection({
26
28
  networkOrConnection,
27
- }: GetOrCreateConnectionOptions): Connection {
29
+ }: GetOrCreateConnectionOptions): SolanaRpcClient {
28
30
  if (typeof networkOrConnection !== "string") {
29
31
  return networkOrConnection;
30
32
  }
31
33
 
32
- return new Connection(
34
+ return createSolanaRpc(
33
35
  networkOrConnection === "mainnet"
34
36
  ? "https://api.mainnet-beta.solana.com"
35
37
  : "https://api.devnet.solana.com",
@@ -37,13 +39,13 @@ export function getOrCreateConnection({
37
39
  }
38
40
 
39
41
  /**
40
- * Legacy function for compatibility during migration
42
+ * Determine the network from the RPC client by checking the genesis hash
41
43
  *
42
- * @param connection - The Solana Connection instance
44
+ * @param rpc - The Solana RPC client
43
45
  * @returns The network type (mainnet or devnet)
44
46
  */
45
- export async function getConnectedNetwork(connection: Connection): Promise<Network> {
46
- const genesisHash = await connection.getGenesisHash();
47
+ export async function getConnectedNetwork(rpc: SolanaRpcClient): Promise<Network> {
48
+ const genesisHash = await rpc.getGenesisHash().send();
47
49
 
48
50
  if (genesisHash === GENESIS_HASH_MAINNET) {
49
51
  return "mainnet";
package/analytics.ts CHANGED
@@ -50,35 +50,14 @@ type ActionEventData = {
50
50
 
51
51
  type EventData = ErrorEventData | ActionEventData;
52
52
 
53
- // Symbol to store the original method on wrapped functions
54
- const ORIGINAL_METHOD = Symbol("originalMethod");
55
-
56
53
  // This is a public client id for the analytics service
57
54
  const publicClientId = "54f2ee2fb3d2b901a829940d70fbfc13";
58
55
 
59
56
  export const Analytics = {
60
57
  identifier: "", // set in cdp.ts
61
- wrapClassWithErrorTracking,
62
- wrapObjectMethodsWithErrorTracking,
63
- sendEvent,
64
- trackAction,
65
- };
66
-
67
- /*
68
- * Deprecated implementation - kept for test compatibility
69
- * Shares the same identifier reference as Analytics
70
- */
71
- export const AnalyticsDeprecated = {
72
- get identifier() {
73
- return Analytics.identifier;
74
- },
75
- set identifier(value: string) {
76
- Analytics.identifier = value;
77
- },
78
- wrapClassWithErrorTracking: wrapClassWithErrorTrackingDeprecated,
79
- wrapObjectMethodsWithErrorTracking: wrapObjectMethodsWithErrorTrackingDeprecated,
80
58
  sendEvent,
81
59
  trackAction,
60
+ trackError,
82
61
  };
83
62
 
84
63
  /**
@@ -171,281 +150,16 @@ function trackAction(params: {
171
150
  }
172
151
 
173
152
  /**
174
- * Gets the original method from a wrapped method, or returns the method itself if it's not wrapped.
175
- *
176
- * @param method - The method to get the original version of.
177
- * @returns The original unwrapped method, or the method itself if it's not wrapped.
178
- */
179
- function getOriginalMethod(
180
- method: (this: unknown, ...args: unknown[]) => Promise<unknown>,
181
- ): (this: unknown, ...args: unknown[]) => Promise<unknown> {
182
- return (
183
- (method as { [ORIGINAL_METHOD]?: (this: unknown, ...args: unknown[]) => Promise<unknown> })[
184
- ORIGINAL_METHOD
185
- ] || method
186
- );
187
- }
188
-
189
- /**
190
- * Creates an interceptor function that prevents recursive calls by checking if the instance is already executing.
153
+ * Track an error that occurred in a method
191
154
  *
192
- * @param executingInstances - A WeakSet tracking instances that are currently executing.
193
- * @param fallbackMethod - The method to call if recursion is not detected.
194
- * @returns A function that intercepts calls and prevents recursion.
155
+ * @param error - The error to track
156
+ * @param method - The method name where the error occurred
195
157
  */
196
- function createRecursiveInterceptor(
197
- executingInstances: WeakSet<object>,
198
- fallbackMethod: (...args: unknown[]) => Promise<unknown>,
199
- ): (...args: unknown[]) => Promise<unknown> {
200
- return function (this: unknown, ...callArgs: unknown[]) {
201
- if (executingInstances.has(this as object)) {
202
- return Promise.resolve(callArgs[0]);
203
- }
204
- return fallbackMethod.apply(this, callArgs);
205
- };
206
- }
207
- /**
208
- * Handles an error that occurred in a method by sending an analytics event and rethrowing the error.
209
- *
210
- * @param error - The error that occurred.
211
- * @param methodName - The name of the method where the error occurred.
212
- */
213
- async function handleMethodError(error: unknown, methodName: string): Promise<void> {
214
- if (!shouldTrackError(error)) {
215
- throw error;
216
- }
217
-
158
+ function trackError(error: unknown, method: string): void {
159
+ if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") return;
160
+ if (!shouldTrackError(error)) return;
218
161
  const { message, stack } = error as Error;
219
- sendEvent({
220
- method: methodName,
221
- message,
222
- stack,
223
- name: "error",
224
- }).catch(() => {
225
- // ignore error
226
- });
227
-
228
- throw error;
229
- }
230
-
231
- /**
232
- * Creates a wrapper function that adds error tracking and recursion protection to a method.
233
- *
234
- * The recursion protection works by temporarily replacing the method with an interceptor
235
- * during the synchronous phase of execution. Any recursive calls (e.g., a method calling
236
- * itself via `this.method()` or `Class.prototype.method()`) happen synchronously and will
237
- * hit the interceptor. After the synchronous phase completes (i.e., `originalMethod.apply()`
238
- * returns a Promise), the method is immediately restored so that concurrent calls arriving
239
- * after an `await` suspension go through the full wrapper instead of being intercepted.
240
- *
241
- * @param originalMethod - The original method to wrap.
242
- * @param methodName - The name of the method being wrapped.
243
- * @param executingInstances - A WeakSet tracking instances that are currently executing.
244
- * @param setMethod - A function to set the method implementation.
245
- * @param getMethod - A function to get the current method implementation.
246
- * @returns A wrapped version of the method with error tracking and recursion protection.
247
- */
248
- function createErrorTrackingWrapper(
249
- originalMethod: (this: unknown, ...args: unknown[]) => Promise<unknown>,
250
- methodName: string,
251
- executingInstances: WeakSet<object>,
252
- setMethod: (method: (...args: unknown[]) => Promise<unknown>) => void,
253
- getMethod: () => (...args: unknown[]) => Promise<unknown>,
254
- ): (this: unknown, ...args: unknown[]) => Promise<unknown> {
255
- return async function (this: unknown, ...args: unknown[]) {
256
- const previousMethod = getMethod();
257
- const recursiveInterceptor = createRecursiveInterceptor(executingInstances, previousMethod);
258
- setMethod(recursiveInterceptor);
259
- executingInstances.add(this as object);
260
-
261
- try {
262
- /*
263
- * Start executing the original method. The synchronous portion runs immediately.
264
- * Any recursive calls (e.g., this.method() or Class.prototype.method()) during
265
- * this synchronous phase will hit the recursiveInterceptor.
266
- */
267
- const resultPromise = originalMethod.apply(this, args);
268
-
269
- /*
270
- * Restore the method immediately after the synchronous phase completes.
271
- * This ensures concurrent calls (arriving after an await suspension) go through
272
- * the full wrapper chain instead of being short-circuited by the interceptor.
273
- */
274
- setMethod(previousMethod);
275
- executingInstances.delete(this as object);
276
-
277
- return await resultPromise;
278
- } catch (error) {
279
- setMethod(previousMethod);
280
- executingInstances.delete(this as object);
281
- return handleMethodError(error, methodName);
282
- }
283
- };
284
- }
285
-
286
- /**
287
- * Wraps all methods of a class with error tracking.
288
- *
289
- * @param ClassToWrap - The class whose prototype methods should be wrapped.
290
- */
291
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
292
- function wrapClassWithErrorTracking(ClassToWrap: any): void {
293
- if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
294
- return;
295
- }
296
-
297
- const methods = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(
298
- name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function",
299
- );
300
-
301
- for (const method of methods) {
302
- const currentMethod = ClassToWrap.prototype[method];
303
- const originalMethod = getOriginalMethod(currentMethod);
304
- const executingInstances = new WeakSet<object>();
305
-
306
- const wrappedMethod = createErrorTrackingWrapper(
307
- originalMethod,
308
- method,
309
- executingInstances,
310
- newMethod => {
311
- ClassToWrap.prototype[method] = newMethod as (
312
- this: unknown,
313
- ...args: unknown[]
314
- ) => Promise<unknown>;
315
- },
316
- () => ClassToWrap.prototype[method] as (...args: unknown[]) => Promise<unknown>,
317
- );
318
-
319
- (wrappedMethod as unknown as { [ORIGINAL_METHOD]: unknown })[ORIGINAL_METHOD] = originalMethod;
320
- ClassToWrap.prototype[method] = wrappedMethod;
321
- }
322
- }
323
-
324
- /**
325
- * Wraps all methods of an object with error tracking.
326
- *
327
- * @param object - The object whose methods should be wrapped.
328
- */
329
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
- function wrapObjectMethodsWithErrorTracking(object: any): void {
331
- if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
332
- return;
333
- }
334
-
335
- const methods = Object.getOwnPropertyNames(object).filter(
336
- name => name !== "constructor" && typeof object[name] === "function",
337
- );
338
-
339
- for (const method of methods) {
340
- const currentMethod = object[method];
341
- const originalMethod = getOriginalMethod(currentMethod);
342
- const executingInstances = new WeakSet<object>();
343
-
344
- const wrappedMethod = createErrorTrackingWrapper(
345
- originalMethod,
346
- method,
347
- executingInstances,
348
- newMethod => {
349
- object[method] = newMethod;
350
- },
351
- () => object[method] as (...args: unknown[]) => Promise<unknown>,
352
- );
353
-
354
- (wrappedMethod as unknown as { [ORIGINAL_METHOD]: unknown })[ORIGINAL_METHOD] = originalMethod;
355
- object[method] = wrappedMethod;
356
- }
357
- }
358
-
359
- /**
360
- * Wraps all methods of a class with error tracking.
361
- *
362
- * @deprecated This is the old implementation that has a bug with methods calling themselves via prototype.
363
- * Use Analytics.wrapClassWithErrorTracking instead.
364
- * Kept for test compatibility.
365
- *
366
- * @param ClassToWrap - The class whose prototype methods should be wrapped.
367
- */
368
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
369
- function wrapClassWithErrorTrackingDeprecated(ClassToWrap: any): void {
370
- if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
371
- return;
372
- }
373
-
374
- const methods = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(
375
- name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function",
376
- );
377
-
378
- for (const method of methods) {
379
- const originalMethod = ClassToWrap.prototype[method];
380
- ClassToWrap.prototype[method] = async function (...args: unknown[]) {
381
- try {
382
- return await originalMethod.apply(this, args);
383
- } catch (error) {
384
- if (!shouldTrackError(error)) {
385
- throw error;
386
- }
387
-
388
- const { message, stack } = error as Error;
389
-
390
- sendEvent({
391
- method,
392
- message,
393
- stack,
394
- name: "error",
395
- }).catch(() => {
396
- // ignore error
397
- });
398
-
399
- throw error;
400
- }
401
- };
402
- }
403
- }
404
-
405
- /**
406
- * Wraps all methods of an object with error tracking.
407
- *
408
- * @deprecated This is the old implementation that has a bug with methods calling themselves via object property.
409
- * Use Analytics.wrapObjectMethodsWithErrorTracking instead.
410
- * Kept for test compatibility.
411
- *
412
- * @param object - The object whose methods should be wrapped.
413
- */
414
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
415
- function wrapObjectMethodsWithErrorTrackingDeprecated(object: any): void {
416
- if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
417
- return;
418
- }
419
-
420
- const methods = Object.getOwnPropertyNames(object).filter(
421
- name => name !== "constructor" && typeof object[name] === "function",
422
- );
423
-
424
- for (const method of methods) {
425
- const originalMethod = object[method];
426
- object[method] = async function (...args: unknown[]) {
427
- try {
428
- return await originalMethod.apply(this, args);
429
- } catch (error) {
430
- if (!shouldTrackError(error)) {
431
- throw error;
432
- }
433
-
434
- const { message, stack } = error as Error;
435
-
436
- sendEvent({
437
- method,
438
- message,
439
- stack,
440
- name: "error",
441
- }).catch(() => {
442
- // ignore error
443
- });
444
-
445
- throw error;
446
- }
447
- };
448
- }
162
+ sendEvent({ method, message, stack, name: "error" }).catch(() => {});
449
163
  }
450
164
 
451
165
  /**
@@ -134,6 +134,7 @@ function requiresWalletAuth(requestMethod: string, requestPath: string): boolean
134
134
  (requestPath?.includes("/accounts") ||
135
135
  requestPath?.includes("/spend-permissions") ||
136
136
  requestPath?.includes("/user-operations/prepare-and-send") ||
137
+ requestPath?.includes("/embedded-wallet-api/") ||
137
138
  requestPath?.endsWith("/end-users") ||
138
139
  requestPath?.endsWith("/end-users/import") ||
139
140
  /\/end-users\/[^/]+\/evm$/.test(requestPath) ||
package/client/cdp.ts CHANGED
@@ -13,6 +13,8 @@ export interface CdpClientOptions {
13
13
  apiKeySecret?: string;
14
14
  /** The wallet secret. */
15
15
  walletSecret?: string;
16
+ /** The CDP project ID. Required for end-user delegation operations (signing, sending). */
17
+ projectId?: string;
16
18
  /** Whether to enable debugging. */
17
19
  debugging?: boolean;
18
20
  /** The host URL to connect to. */
@@ -50,6 +52,7 @@ export class CdpClient {
50
52
  * CDP_API_KEY_ID=your-api-key-id
51
53
  * CDP_API_KEY_SECRET=your-api-key-secret
52
54
  * CDP_WALLET_SECRET=your-wallet-secret
55
+ * CDP_PROJECT_ID=your-project-id
53
56
  * ```
54
57
  *
55
58
  * Or passed as options to the constructor:
@@ -59,6 +62,7 @@ export class CdpClient {
59
62
  * apiKeyId: "your-api-key-id",
60
63
  * apiKeySecret: "your-api-key-secret",
61
64
  * walletSecret: "your-wallet-secret",
65
+ * projectId: "your-project-id",
62
66
  * });
63
67
  * ```
64
68
  *
@@ -83,6 +87,7 @@ We recommend using https://github.com/Schniz/fnm for managing your Node.js versi
83
87
  const apiKeyId = options.apiKeyId ?? process.env.CDP_API_KEY_ID ?? process.env.CDP_API_KEY_NAME;
84
88
  const apiKeySecret = options.apiKeySecret ?? process.env.CDP_API_KEY_SECRET;
85
89
  const walletSecret = options.walletSecret ?? process.env.CDP_WALLET_SECRET;
90
+ const projectId = options.projectId ?? process.env.CDP_PROJECT_ID;
86
91
 
87
92
  if (!apiKeyId || !apiKeySecret) {
88
93
  throw new Error(`
@@ -132,16 +137,9 @@ For more information, see: https://github.com/coinbase/cdp-sdk/blob/main/typescr
132
137
  Analytics.identifier = apiKeyId;
133
138
  }
134
139
 
135
- if (process.env.DISABLE_CDP_ERROR_REPORTING !== "true") {
136
- Analytics.wrapClassWithErrorTracking(CdpClient);
137
- Analytics.wrapClassWithErrorTracking(EvmClient);
138
- Analytics.wrapClassWithErrorTracking(SolanaClient);
139
- Analytics.wrapClassWithErrorTracking(PoliciesClient);
140
- }
141
-
142
140
  this.evm = new EvmClient();
143
141
  this.solana = new SolanaClient();
144
142
  this.policies = new PoliciesClient();
145
- this.endUser = new CDPEndUserClient();
143
+ this.endUser = new CDPEndUserClient(projectId);
146
144
  }
147
145
  }