@coinbase/cdp-sdk 1.28.0 → 1.30.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 (274) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/_cjs/accounts/evm/networkCapabilities.js +101 -0
  3. package/_cjs/accounts/evm/networkCapabilities.js.map +1 -1
  4. package/_cjs/accounts/evm/toEvmServerAccount.js +12 -1
  5. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  6. package/_cjs/accounts/evm/toEvmSmartAccount.js +12 -1
  7. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  8. package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +10 -0
  9. package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
  10. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +11 -1
  11. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  12. package/_cjs/accounts/solana/toSolanaAccount.js +41 -1
  13. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  14. package/_cjs/actions/Quote.js +106 -0
  15. package/_cjs/actions/Quote.js.map +1 -0
  16. package/_cjs/actions/evm/fund/fund.js +5 -5
  17. package/_cjs/actions/evm/fund/fund.js.map +1 -1
  18. package/_cjs/actions/evm/fund/quoteFund.js +7 -7
  19. package/_cjs/actions/evm/fund/quoteFund.js.map +1 -1
  20. package/_cjs/actions/evm/getUserOperation.js +1 -0
  21. package/_cjs/actions/evm/getUserOperation.js.map +1 -1
  22. package/_cjs/actions/evm/spend-permissions/account.use.js +33 -0
  23. package/_cjs/actions/evm/spend-permissions/account.use.js.map +1 -0
  24. package/_cjs/actions/evm/spend-permissions/smartAccount.use.js +35 -0
  25. package/_cjs/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
  26. package/_cjs/actions/evm/spend-permissions/types.js.map +1 -0
  27. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +1 -0
  28. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  29. package/_cjs/actions/solana/fund/fund.js +50 -0
  30. package/_cjs/actions/solana/fund/fund.js.map +1 -0
  31. package/_cjs/actions/solana/fund/quoteFund.js +47 -0
  32. package/_cjs/actions/solana/fund/quoteFund.js.map +1 -0
  33. package/_cjs/actions/solana/sendTransaction.js +1 -0
  34. package/_cjs/actions/solana/sendTransaction.js.map +1 -1
  35. package/_cjs/actions/solana/signTransaction.js +1 -0
  36. package/_cjs/actions/solana/signTransaction.js.map +1 -1
  37. package/_cjs/actions/types.js +3 -0
  38. package/{_esm/actions/evm/fund → _cjs/actions}/types.js.map +1 -1
  39. package/_cjs/actions/{evm/fund/waitForFundOperationReceipt.js → waitForFundOperationReceipt.js} +2 -2
  40. package/_cjs/actions/waitForFundOperationReceipt.js.map +1 -0
  41. package/_cjs/auth/hooks/axios/withAuth.js +3 -0
  42. package/_cjs/auth/hooks/axios/withAuth.js.map +1 -1
  43. package/_cjs/auth/utils/http.js +2 -1
  44. package/_cjs/auth/utils/http.js.map +1 -1
  45. package/_cjs/client/evm/evm.js +51 -1
  46. package/_cjs/client/evm/evm.js.map +1 -1
  47. package/_cjs/client/solana/solana.js.map +1 -1
  48. package/_cjs/index.js +5 -1
  49. package/_cjs/index.js.map +1 -1
  50. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +54 -7
  51. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  52. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +14 -1
  53. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  54. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +76 -4
  55. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  56. package/_cjs/openapi-client/generated/index.msw.js +2 -0
  57. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  58. package/_cjs/openapi-client/generated/onramp/onramp.js +30 -0
  59. package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -0
  60. package/_cjs/openapi-client/generated/onramp/onramp.msw.js +98 -0
  61. package/_cjs/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
  62. package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js +15 -0
  63. package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
  64. package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +69 -0
  65. package/_cjs/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
  66. package/_cjs/openapi-client/index.js +2 -0
  67. package/_cjs/openapi-client/index.js.map +1 -1
  68. package/_cjs/spend-permissions/constants.js +716 -0
  69. package/_cjs/spend-permissions/constants.js.map +1 -0
  70. package/_cjs/spend-permissions/types.js +3 -0
  71. package/_cjs/{actions/evm/fund → spend-permissions}/types.js.map +1 -1
  72. package/_cjs/version.js +1 -1
  73. package/_esm/accounts/evm/networkCapabilities.js +101 -0
  74. package/_esm/accounts/evm/networkCapabilities.js.map +1 -1
  75. package/_esm/accounts/evm/toEvmServerAccount.js +12 -1
  76. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  77. package/_esm/accounts/evm/toEvmSmartAccount.js +12 -1
  78. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  79. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +10 -0
  80. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
  81. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +11 -1
  82. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  83. package/_esm/accounts/solana/toSolanaAccount.js +41 -1
  84. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  85. package/_esm/actions/Quote.js +101 -0
  86. package/_esm/actions/Quote.js.map +1 -0
  87. package/_esm/actions/evm/fund/fund.js +5 -5
  88. package/_esm/actions/evm/fund/fund.js.map +1 -1
  89. package/_esm/actions/evm/fund/quoteFund.js +7 -7
  90. package/_esm/actions/evm/fund/quoteFund.js.map +1 -1
  91. package/_esm/actions/evm/getUserOperation.js +1 -0
  92. package/_esm/actions/evm/getUserOperation.js.map +1 -1
  93. package/_esm/actions/evm/spend-permissions/account.use.js +30 -0
  94. package/_esm/actions/evm/spend-permissions/account.use.js.map +1 -0
  95. package/_esm/actions/evm/spend-permissions/smartAccount.use.js +32 -0
  96. package/_esm/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
  97. package/_esm/actions/evm/spend-permissions/types.js.map +1 -0
  98. package/_esm/actions/evm/transfer/accountTransferStrategy.js +1 -0
  99. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  100. package/_esm/actions/solana/fund/fund.js +47 -0
  101. package/_esm/actions/solana/fund/fund.js.map +1 -0
  102. package/_esm/actions/solana/fund/quoteFund.js +44 -0
  103. package/_esm/actions/solana/fund/quoteFund.js.map +1 -0
  104. package/_esm/actions/solana/sendTransaction.js +1 -0
  105. package/_esm/actions/solana/sendTransaction.js.map +1 -1
  106. package/_esm/actions/solana/signTransaction.js +1 -0
  107. package/_esm/actions/solana/signTransaction.js.map +1 -1
  108. package/_esm/actions/types.js +2 -0
  109. package/_esm/actions/types.js.map +1 -0
  110. package/_esm/actions/{evm/fund/waitForFundOperationReceipt.js → waitForFundOperationReceipt.js} +2 -2
  111. package/_esm/actions/waitForFundOperationReceipt.js.map +1 -0
  112. package/_esm/auth/hooks/axios/withAuth.js +3 -0
  113. package/_esm/auth/hooks/axios/withAuth.js.map +1 -1
  114. package/_esm/auth/utils/http.js +2 -1
  115. package/_esm/auth/utils/http.js.map +1 -1
  116. package/_esm/client/evm/evm.js +51 -1
  117. package/_esm/client/evm/evm.js.map +1 -1
  118. package/_esm/client/solana/solana.js +2 -2
  119. package/_esm/client/solana/solana.js.map +1 -1
  120. package/_esm/index.js +2 -1
  121. package/_esm/index.js.map +1 -1
  122. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +52 -5
  123. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  124. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +12 -0
  125. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  126. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +73 -3
  127. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  128. package/_esm/openapi-client/generated/index.msw.js +2 -0
  129. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  130. package/_esm/openapi-client/generated/onramp/onramp.js +25 -0
  131. package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -0
  132. package/_esm/openapi-client/generated/onramp/onramp.msw.js +90 -0
  133. package/_esm/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
  134. package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js +11 -0
  135. package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.js.map +1 -0
  136. package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js +63 -0
  137. package/_esm/openapi-client/generated/x402-facilitator/x402-facilitator.msw.js.map +1 -0
  138. package/_esm/openapi-client/index.js +2 -0
  139. package/_esm/openapi-client/index.js.map +1 -1
  140. package/_esm/spend-permissions/constants.js +713 -0
  141. package/_esm/spend-permissions/constants.js.map +1 -0
  142. package/_esm/spend-permissions/types.js +2 -0
  143. package/_esm/spend-permissions/types.js.map +1 -0
  144. package/_esm/version.js +1 -1
  145. package/_types/accounts/evm/networkCapabilities.d.ts +101 -0
  146. package/_types/accounts/evm/networkCapabilities.d.ts.map +1 -1
  147. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  148. package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
  149. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  150. package/_types/accounts/evm/toNetworkScopedEvmServerAccount.d.ts.map +1 -1
  151. package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
  152. package/_types/accounts/evm/types.d.ts +15 -9
  153. package/_types/accounts/evm/types.d.ts.map +1 -1
  154. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  155. package/_types/actions/Quote.d.ts +97 -0
  156. package/_types/actions/Quote.d.ts.map +1 -0
  157. package/_types/actions/evm/fund/fund.d.ts +3 -7
  158. package/_types/actions/evm/fund/fund.d.ts.map +1 -1
  159. package/_types/actions/evm/fund/quoteFund.d.ts +4 -7
  160. package/_types/actions/evm/fund/quoteFund.d.ts.map +1 -1
  161. package/_types/actions/evm/getUserOperation.d.ts.map +1 -1
  162. package/_types/actions/evm/spend-permissions/account.use.d.ts +15 -0
  163. package/_types/actions/evm/spend-permissions/account.use.d.ts.map +1 -0
  164. package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts +15 -0
  165. package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts.map +1 -0
  166. package/_types/actions/evm/spend-permissions/types.d.ts +13 -0
  167. package/_types/actions/evm/spend-permissions/types.d.ts.map +1 -0
  168. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  169. package/_types/actions/evm/types.d.ts +82 -7
  170. package/_types/actions/evm/types.d.ts.map +1 -1
  171. package/_types/actions/solana/fund/fund.d.ts +19 -0
  172. package/_types/actions/solana/fund/fund.d.ts.map +1 -0
  173. package/_types/actions/solana/fund/quoteFund.d.ts +20 -0
  174. package/_types/actions/solana/fund/quoteFund.d.ts.map +1 -0
  175. package/_types/actions/solana/sendTransaction.d.ts +8 -2
  176. package/_types/actions/solana/sendTransaction.d.ts.map +1 -1
  177. package/_types/actions/solana/signTransaction.d.ts +8 -2
  178. package/_types/actions/solana/signTransaction.d.ts.map +1 -1
  179. package/_types/actions/solana/types.d.ts +99 -3
  180. package/_types/actions/solana/types.d.ts.map +1 -1
  181. package/_types/actions/types.d.ts +37 -0
  182. package/_types/actions/types.d.ts.map +1 -0
  183. package/_types/actions/{evm/fund/waitForFundOperationReceipt.d.ts → waitForFundOperationReceipt.d.ts} +2 -2
  184. package/_types/actions/waitForFundOperationReceipt.d.ts.map +1 -0
  185. package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -1
  186. package/_types/auth/utils/http.d.ts.map +1 -1
  187. package/_types/client/evm/evm.d.ts +19 -1
  188. package/_types/client/evm/evm.d.ts.map +1 -1
  189. package/_types/client/evm/evm.types.d.ts +29 -2
  190. package/_types/client/evm/evm.types.d.ts.map +1 -1
  191. package/_types/client/solana/solana.d.ts +5 -3
  192. package/_types/client/solana/solana.d.ts.map +1 -1
  193. package/_types/index.d.ts +3 -1
  194. package/_types/index.d.ts.map +1 -1
  195. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +356 -20
  196. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  197. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +7 -1
  198. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  199. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +2 -0
  200. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
  201. package/_types/openapi-client/generated/index.msw.d.ts +2 -0
  202. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  203. package/_types/openapi-client/generated/onramp/onramp.d.ts +28 -0
  204. package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -0
  205. package/_types/openapi-client/generated/onramp/onramp.msw.d.ts +8 -0
  206. package/_types/openapi-client/generated/onramp/onramp.msw.d.ts.map +1 -0
  207. package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts +20 -0
  208. package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.d.ts.map +1 -0
  209. package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts +6 -0
  210. package/_types/openapi-client/generated/x402-facilitator/x402-facilitator.msw.d.ts.map +1 -0
  211. package/_types/openapi-client/index.d.ts +4 -0
  212. package/_types/openapi-client/index.d.ts.map +1 -1
  213. package/_types/spend-permissions/constants.d.ts +1357 -0
  214. package/_types/spend-permissions/constants.d.ts.map +1 -0
  215. package/_types/spend-permissions/types.d.ts +30 -0
  216. package/_types/spend-permissions/types.d.ts.map +1 -0
  217. package/_types/version.d.ts +1 -1
  218. package/accounts/evm/networkCapabilities.ts +101 -0
  219. package/accounts/evm/toEvmServerAccount.ts +26 -11
  220. package/accounts/evm/toEvmSmartAccount.ts +30 -15
  221. package/accounts/evm/toNetworkScopedEvmServerAccount.ts +20 -5
  222. package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +21 -6
  223. package/accounts/evm/types.ts +34 -12
  224. package/accounts/solana/toSolanaAccount.ts +58 -3
  225. package/actions/Quote.ts +154 -0
  226. package/actions/evm/fund/fund.ts +10 -14
  227. package/actions/evm/fund/quoteFund.ts +13 -16
  228. package/actions/evm/getUserOperation.ts +1 -0
  229. package/actions/evm/spend-permissions/account.use.ts +48 -0
  230. package/actions/evm/spend-permissions/smartAccount.use.ts +49 -0
  231. package/actions/evm/spend-permissions/types.ts +13 -0
  232. package/actions/evm/transfer/accountTransferStrategy.ts +2 -0
  233. package/actions/evm/types.ts +88 -7
  234. package/actions/solana/fund/fund.ts +71 -0
  235. package/actions/solana/fund/quoteFund.ts +77 -0
  236. package/actions/solana/sendTransaction.ts +10 -2
  237. package/actions/solana/signTransaction.ts +10 -2
  238. package/actions/solana/types.ts +113 -2
  239. package/actions/types.ts +39 -0
  240. package/actions/{evm/fund/waitForFundOperationReceipt.ts → waitForFundOperationReceipt.ts} +2 -2
  241. package/auth/hooks/axios/withAuth.ts +3 -0
  242. package/auth/utils/http.ts +2 -1
  243. package/client/evm/evm.ts +61 -1
  244. package/client/evm/evm.types.ts +31 -0
  245. package/client/solana/solana.ts +10 -5
  246. package/index.ts +6 -1
  247. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +400 -26
  248. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +89 -3
  249. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +23 -0
  250. package/openapi-client/generated/index.msw.ts +2 -0
  251. package/openapi-client/generated/onramp/onramp.msw.ts +135 -0
  252. package/openapi-client/generated/onramp/onramp.ts +54 -0
  253. package/openapi-client/generated/x402-facilitator/x402-facilitator.msw.ts +85 -0
  254. package/openapi-client/generated/x402-facilitator/x402-facilitator.ts +34 -0
  255. package/openapi-client/index.ts +2 -0
  256. package/package.json +1 -1
  257. package/spend-permissions/constants.ts +713 -0
  258. package/spend-permissions/types.ts +42 -0
  259. package/version.ts +1 -1
  260. package/_cjs/actions/evm/fund/Quote.js +0 -63
  261. package/_cjs/actions/evm/fund/Quote.js.map +0 -1
  262. package/_cjs/actions/evm/fund/waitForFundOperationReceipt.js.map +0 -1
  263. package/_esm/actions/evm/fund/Quote.js +0 -59
  264. package/_esm/actions/evm/fund/Quote.js.map +0 -1
  265. package/_esm/actions/evm/fund/waitForFundOperationReceipt.js.map +0 -1
  266. package/_types/actions/evm/fund/Quote.d.ts +0 -51
  267. package/_types/actions/evm/fund/Quote.d.ts.map +0 -1
  268. package/_types/actions/evm/fund/types.d.ts +0 -16
  269. package/_types/actions/evm/fund/types.d.ts.map +0 -1
  270. package/_types/actions/evm/fund/waitForFundOperationReceipt.d.ts.map +0 -1
  271. package/actions/evm/fund/Quote.ts +0 -83
  272. package/actions/evm/fund/types.ts +0 -16
  273. /package/_cjs/actions/evm/{fund → spend-permissions}/types.js +0 -0
  274. /package/_esm/actions/evm/{fund → spend-permissions}/types.js +0 -0
@@ -1,11 +1,22 @@
1
1
  import { Account, SolanaAccount } from "./types.js";
2
+ import { SolanaQuote } from "../../actions/Quote.js";
3
+ import { SolanaFundOptions, fund } from "../../actions/solana/fund/fund.js";
4
+ import { SolanaQuoteFundOptions, quoteFund } from "../../actions/solana/fund/quoteFund.js";
2
5
  import { requestFaucet } from "../../actions/solana/requestFaucet.js";
6
+ import { sendTransaction, SendTransactionResult } from "../../actions/solana/sendTransaction.js";
3
7
  import { signMessage } from "../../actions/solana/signMessage.js";
4
- import { signTransaction } from "../../actions/solana/signTransaction.js";
8
+ import { signTransaction, SignTransactionResult } from "../../actions/solana/signTransaction.js";
5
9
  import { transfer, type TransferOptions } from "../../actions/solana/transfer.js";
10
+ import { FundOperationResult } from "../../actions/types.js";
11
+ import {
12
+ WaitForFundOperationOptions,
13
+ WaitForFundOperationResult,
14
+ waitForFundOperationReceipt,
15
+ } from "../../actions/waitForFundOperationReceipt.js";
6
16
  import { Analytics } from "../../analytics.js";
7
17
  import {
8
18
  RequestFaucetOptions,
19
+ SendTransactionOptions,
9
20
  SignatureResult,
10
21
  SignMessageOptions,
11
22
  SignTransactionOptions,
@@ -35,6 +46,7 @@ export function toSolanaAccount(
35
46
  const account: SolanaAccount = {
36
47
  address: options.account.address,
37
48
  name: options.account.name,
49
+ policies: options.account.policies,
38
50
  async requestFaucet(options: Omit<RequestFaucetOptions, "address">): Promise<SignatureResult> {
39
51
  Analytics.trackAction({
40
52
  action: "request_faucet",
@@ -59,7 +71,7 @@ export function toSolanaAccount(
59
71
  },
60
72
  async signTransaction(
61
73
  options: Omit<SignTransactionOptions, "address">,
62
- ): Promise<SignatureResult> {
74
+ ): Promise<SignTransactionResult> {
63
75
  Analytics.trackAction({
64
76
  action: "sign_transaction",
65
77
  accountType: "solana",
@@ -70,7 +82,18 @@ export function toSolanaAccount(
70
82
  address: account.address,
71
83
  });
72
84
  },
73
- policies: options.account.policies,
85
+ async sendTransaction(
86
+ options: Omit<SendTransactionOptions, "address">,
87
+ ): Promise<SendTransactionResult> {
88
+ Analytics.trackAction({
89
+ action: "send_transaction",
90
+ accountType: "solana",
91
+ });
92
+
93
+ return sendTransaction(apiClient, {
94
+ ...options,
95
+ });
96
+ },
74
97
  async transfer(options: Omit<TransferOptions, "from">): Promise<SignatureResult> {
75
98
  Analytics.trackAction({
76
99
  action: "transfer",
@@ -85,6 +108,38 @@ export function toSolanaAccount(
85
108
  from: account.address,
86
109
  });
87
110
  },
111
+ async quoteFund(options: Omit<SolanaQuoteFundOptions, "address">): Promise<SolanaQuote> {
112
+ Analytics.trackAction({
113
+ action: "quote_fund",
114
+ accountType: "solana",
115
+ });
116
+
117
+ return quoteFund(apiClient, {
118
+ ...options,
119
+ address: account.address,
120
+ });
121
+ },
122
+ async fund(options: Omit<SolanaFundOptions, "address">): Promise<FundOperationResult> {
123
+ Analytics.trackAction({
124
+ action: "fund",
125
+ accountType: "solana",
126
+ });
127
+
128
+ return fund(apiClient, {
129
+ ...options,
130
+ address: account.address,
131
+ });
132
+ },
133
+ async waitForFundOperationReceipt(
134
+ options: WaitForFundOperationOptions,
135
+ ): Promise<WaitForFundOperationResult> {
136
+ Analytics.trackAction({
137
+ action: "wait_for_fund_operation_receipt",
138
+ accountType: "solana",
139
+ });
140
+
141
+ return waitForFundOperationReceipt(apiClient, options);
142
+ },
88
143
  };
89
144
 
90
145
  return account;
@@ -0,0 +1,154 @@
1
+ import { FundOperationResult } from "./types.js";
2
+ import { CdpOpenApiClientType } from "../openapi-client/index.js";
3
+
4
+ /**
5
+ * Base class representing a funding quote that can be executed.
6
+ */
7
+ abstract class BaseQuote {
8
+ /** Quote for the transfer. */
9
+ public quoteId: string;
10
+ /** The amount in fiat currency. */
11
+ public fiatAmount: string;
12
+ /** The fiat currency. */
13
+ public fiatCurrency: string;
14
+ /** The amount in the token to transfer. */
15
+ public tokenAmount: string;
16
+ /** The token to transfer. */
17
+ public token: string;
18
+ /** Fees in the token to transfer. */
19
+ public fees: {
20
+ /** The type of fee. */
21
+ type: "exchange_fee" | "network_fee";
22
+ amount: string;
23
+ currency: string;
24
+ }[];
25
+
26
+ protected apiClient: CdpOpenApiClientType;
27
+
28
+ /**
29
+ * Creates a new BaseQuote instance.
30
+ *
31
+ * @param apiClient - The API client.
32
+ * @param quoteId - The quote ID.
33
+ * @param fiatAmount - The amount in fiat currency.
34
+ * @param fiatCurrency - The fiat currency.
35
+ * @param tokenAmount - The amount in the token to transfer.
36
+ * @param token - The token to transfer.
37
+ * @param fees - Fees for the transfer.
38
+ */
39
+ constructor(
40
+ apiClient: CdpOpenApiClientType,
41
+ quoteId: string,
42
+ fiatAmount: string,
43
+ fiatCurrency: string,
44
+ tokenAmount: string,
45
+ token: string,
46
+ fees: {
47
+ type: "exchange_fee" | "network_fee";
48
+ amount: string;
49
+ currency: string;
50
+ }[],
51
+ ) {
52
+ this.apiClient = apiClient;
53
+ this.quoteId = quoteId;
54
+ this.fiatAmount = fiatAmount;
55
+ this.fiatCurrency = fiatCurrency;
56
+ this.tokenAmount = tokenAmount;
57
+ this.token = token;
58
+ this.fees = fees;
59
+ }
60
+
61
+ /**
62
+ * Executes the quote to perform the actual fund transfer.
63
+ *
64
+ * @returns A promise that resolves to the result of the executed quote.
65
+ */
66
+ async execute(): Promise<FundOperationResult> {
67
+ const transfer = await this.apiClient.executePaymentTransferQuote(this.quoteId);
68
+
69
+ return {
70
+ id: transfer.id,
71
+ network: transfer.target.network,
72
+ targetAmount: transfer.targetAmount,
73
+ targetCurrency: transfer.targetCurrency,
74
+ status: transfer.status,
75
+ transactionHash: transfer.transactionHash,
76
+ };
77
+ }
78
+ }
79
+
80
+ /**
81
+ * A class representing an EVM funding quote that can be executed.
82
+ */
83
+ export class EvmQuote extends BaseQuote {
84
+ /** Network to transfer the funds to (EVM networks). */
85
+ public network: "base" | "ethereum";
86
+
87
+ /**
88
+ * Creates a new EvmQuote instance.
89
+ *
90
+ * @param apiClient - The API client.
91
+ * @param quoteId - The quote ID.
92
+ * @param network - The EVM network to transfer funds to.
93
+ * @param fiatAmount - The amount in fiat currency.
94
+ * @param fiatCurrency - The fiat currency.
95
+ * @param tokenAmount - The amount in the token to transfer.
96
+ * @param token - The token to transfer.
97
+ * @param fees - Fees for the transfer.
98
+ */
99
+ constructor(
100
+ apiClient: CdpOpenApiClientType,
101
+ quoteId: string,
102
+ network: "base" | "ethereum",
103
+ fiatAmount: string,
104
+ fiatCurrency: string,
105
+ tokenAmount: string,
106
+ token: string,
107
+ fees: {
108
+ type: "exchange_fee" | "network_fee";
109
+ amount: string;
110
+ currency: string;
111
+ }[],
112
+ ) {
113
+ super(apiClient, quoteId, fiatAmount, fiatCurrency, tokenAmount, token, fees);
114
+ this.network = network;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * A class representing a Solana funding quote that can be executed.
120
+ */
121
+ export class SolanaQuote extends BaseQuote {
122
+ /** Network to transfer the funds to (Solana). */
123
+ public network: "solana";
124
+
125
+ /**
126
+ * Creates a new SolanaQuote instance.
127
+ *
128
+ * @param apiClient - The API client.
129
+ * @param quoteId - The quote ID.
130
+ * @param network - The Solana network to transfer funds to.
131
+ * @param fiatAmount - The amount in fiat currency.
132
+ * @param fiatCurrency - The fiat currency.
133
+ * @param tokenAmount - The amount in the token to transfer.
134
+ * @param token - The token to transfer.
135
+ * @param fees - Fees for the transfer.
136
+ */
137
+ constructor(
138
+ apiClient: CdpOpenApiClientType,
139
+ quoteId: string,
140
+ network: "solana",
141
+ fiatAmount: string,
142
+ fiatCurrency: string,
143
+ tokenAmount: string,
144
+ token: string,
145
+ fees: {
146
+ type: "exchange_fee" | "network_fee";
147
+ amount: string;
148
+ currency: string;
149
+ }[],
150
+ ) {
151
+ super(apiClient, quoteId, fiatAmount, fiatCurrency, tokenAmount, token, fees);
152
+ this.network = network;
153
+ }
154
+ }
@@ -1,23 +1,19 @@
1
1
  import { formatUnits } from "viem";
2
2
 
3
- import { FundOperationResult } from "./types.js";
4
3
  import { UserInputValidationError } from "../../../errors.js";
5
4
  import {
6
5
  CreatePaymentTransferQuoteBodySourceType,
7
6
  CreatePaymentTransferQuoteBodyTargetType,
8
7
  type CdpOpenApiClientType,
9
8
  } from "../../../openapi-client/index.js";
9
+ import { BaseFundOptions, FundOperationResult } from "../../types.js";
10
10
 
11
11
  /**
12
12
  * Options for funding an EVM account.
13
13
  */
14
- export interface FundOptions {
15
- /** The address of the account. */
16
- address: string;
14
+ export interface EvmFundOptions extends BaseFundOptions {
17
15
  /** The network to request funds from. */
18
16
  network: "base" | "ethereum";
19
- /** The amount to fund the account with, in atomic units (wei) of the token. */
20
- amount: bigint;
21
17
  /** The token to request funds for. */
22
18
  token: "eth" | "usdc";
23
19
  }
@@ -32,8 +28,15 @@ export interface FundOptions {
32
28
  */
33
29
  export async function fund(
34
30
  apiClient: CdpOpenApiClientType,
35
- options: FundOptions,
31
+ options: EvmFundOptions,
36
32
  ): Promise<FundOperationResult> {
33
+ if (options.token !== "eth" && options.token !== "usdc") {
34
+ throw new UserInputValidationError("Invalid token, must be eth or usdc");
35
+ }
36
+
37
+ const decimals = options.token === "eth" ? 18 : 6;
38
+ const amount = formatUnits(options.amount, decimals);
39
+
37
40
  const paymentMethods = await apiClient.getPaymentMethods();
38
41
  const cardPaymentMethod = paymentMethods.find(
39
42
  method => method.type === "card" && method.actions.includes("source"),
@@ -43,13 +46,6 @@ export async function fund(
43
46
  throw new Error("No card found to fund account");
44
47
  }
45
48
 
46
- if (options.token !== "eth" && options.token !== "usdc") {
47
- throw new UserInputValidationError("Invalid token, must be eth or usdc");
48
- }
49
-
50
- const decimals = options.token === "eth" ? 18 : 6;
51
- const amount = formatUnits(options.amount, decimals);
52
-
53
49
  const response = await apiClient.createPaymentTransferQuote({
54
50
  sourceType: CreatePaymentTransferQuoteBodySourceType.payment_method,
55
51
  source: {
@@ -1,23 +1,20 @@
1
1
  import { formatUnits } from "viem";
2
2
 
3
- import { Quote } from "./Quote.js";
4
3
  import { UserInputValidationError } from "../../../errors.js";
5
4
  import {
6
5
  CreatePaymentTransferQuoteBodySourceType,
7
6
  CreatePaymentTransferQuoteBodyTargetType,
8
7
  type CdpOpenApiClientType,
9
8
  } from "../../../openapi-client/index.js";
9
+ import { EvmQuote } from "../../Quote.js";
10
+ import { BaseQuoteFundOptions } from "../../types.js";
10
11
 
11
12
  /**
12
13
  * Options for getting a quote to fund an EVM account.
13
14
  */
14
- export interface QuoteFundOptions {
15
- /** The address of the account. */
16
- address: string;
15
+ export interface EvmQuoteFundOptions extends BaseQuoteFundOptions {
17
16
  /** The network to request funds from. */
18
17
  network: "base" | "ethereum";
19
- /** The amount to fund the account with, in atomic units (wei) of the token. */
20
- amount: bigint;
21
18
  /** The token to request funds for. */
22
19
  token: "eth" | "usdc";
23
20
  }
@@ -32,8 +29,15 @@ export interface QuoteFundOptions {
32
29
  */
33
30
  export async function quoteFund(
34
31
  apiClient: CdpOpenApiClientType,
35
- options: QuoteFundOptions,
36
- ): Promise<Quote> {
32
+ options: EvmQuoteFundOptions,
33
+ ): Promise<EvmQuote> {
34
+ if (options.token !== "eth" && options.token !== "usdc") {
35
+ throw new UserInputValidationError("Invalid token, must be eth or usdc");
36
+ }
37
+
38
+ const decimals = options.token === "eth" ? 18 : 6;
39
+ const amount = formatUnits(options.amount, decimals);
40
+
37
41
  const paymentMethods = await apiClient.getPaymentMethods();
38
42
  const cardPaymentMethod = paymentMethods.find(
39
43
  method => method.type === "card" && method.actions.includes("source"),
@@ -43,13 +47,6 @@ export async function quoteFund(
43
47
  throw new Error("No card found to fund account");
44
48
  }
45
49
 
46
- if (options.token !== "eth" && options.token !== "usdc") {
47
- throw new UserInputValidationError("Invalid token, must be eth or usdc");
48
- }
49
-
50
- const decimals = options.token === "eth" ? 18 : 6;
51
- const amount = formatUnits(options.amount, decimals);
52
-
53
50
  const response = await apiClient.createPaymentTransferQuote({
54
51
  sourceType: CreatePaymentTransferQuoteBodySourceType.payment_method,
55
52
  source: {
@@ -65,7 +62,7 @@ export async function quoteFund(
65
62
  currency: options.token,
66
63
  });
67
64
 
68
- return new Quote(
65
+ return new EvmQuote(
69
66
  apiClient,
70
67
  response.transfer.id,
71
68
  options.network,
@@ -39,5 +39,6 @@ export async function getUserOperation(
39
39
  status: userOp.status,
40
40
  transactionHash: userOp.transactionHash as Hex | undefined,
41
41
  userOpHash: userOp.userOpHash as Hex,
42
+ receipts: userOp.receipts,
42
43
  };
43
44
  }
@@ -0,0 +1,48 @@
1
+ import { encodeFunctionData } from "viem";
2
+
3
+ import {
4
+ SPEND_PERMISSION_MANAGER_ABI,
5
+ SPEND_PERMISSION_MANAGER_ADDRESS,
6
+ } from "../../../spend-permissions/constants.js";
7
+ import { serializeEIP1559Transaction } from "../../../utils/serializeTransaction.js";
8
+
9
+ import type { UseSpendPermissionOptions } from "./types.js";
10
+ import type {
11
+ CdpOpenApiClientType,
12
+ SendEvmTransactionBodyNetwork,
13
+ } from "../../../openapi-client/index.js";
14
+ import type { Address, Hex } from "../../../types/misc.js";
15
+ import type { TransactionResult } from "../sendTransaction.js";
16
+
17
+ /**
18
+ * Use a spend permission to spend tokens.
19
+ *
20
+ * @param apiClient - The API client to use.
21
+ * @param address - The address of the account to use the spend permission on.
22
+ * @param options - The options for the spend permission.
23
+ *
24
+ * @returns The transaction hash of the spend permission.
25
+ */
26
+ export async function useSpendPermission(
27
+ apiClient: CdpOpenApiClientType,
28
+ address: Address,
29
+ options: UseSpendPermissionOptions,
30
+ ): Promise<TransactionResult> {
31
+ const { spendPermission, value, network } = options;
32
+
33
+ const result = await apiClient.sendEvmTransaction(address, {
34
+ transaction: serializeEIP1559Transaction({
35
+ to: SPEND_PERMISSION_MANAGER_ADDRESS,
36
+ data: encodeFunctionData({
37
+ abi: SPEND_PERMISSION_MANAGER_ABI,
38
+ functionName: "spend",
39
+ args: [spendPermission, value],
40
+ }),
41
+ }),
42
+ network: network as SendEvmTransactionBodyNetwork,
43
+ });
44
+
45
+ return {
46
+ transactionHash: result.transactionHash as Hex,
47
+ };
48
+ }
@@ -0,0 +1,49 @@
1
+ import { encodeFunctionData } from "viem";
2
+
3
+ import {
4
+ SPEND_PERMISSION_MANAGER_ABI,
5
+ SPEND_PERMISSION_MANAGER_ADDRESS,
6
+ } from "../../../spend-permissions/constants.js";
7
+ import { type SendUserOperationReturnType, sendUserOperation } from "../sendUserOperation.js";
8
+
9
+ import type { UseSpendPermissionOptions } from "./types.js";
10
+ import type { EvmSmartAccount } from "../../../accounts/evm/types.js";
11
+ import type {
12
+ CdpOpenApiClientType,
13
+ EvmUserOperationNetwork,
14
+ } from "../../../openapi-client/index.js";
15
+
16
+ /**
17
+ * Use a spend permission to spend tokens.
18
+ *
19
+ * @param apiClient - The API client to use.
20
+ * @param account - The smart account to use.
21
+ * @param options - The options for the spend permission.
22
+ *
23
+ * @returns The result of the spend permission.
24
+ */
25
+ export function useSpendPermission(
26
+ apiClient: CdpOpenApiClientType,
27
+ account: EvmSmartAccount,
28
+ options: UseSpendPermissionOptions,
29
+ ): Promise<SendUserOperationReturnType> {
30
+ const { spendPermission, value, network } = options;
31
+
32
+ const data = encodeFunctionData({
33
+ abi: SPEND_PERMISSION_MANAGER_ABI,
34
+ functionName: "spend",
35
+ args: [spendPermission, value],
36
+ });
37
+
38
+ return sendUserOperation(apiClient, {
39
+ smartAccount: account,
40
+ network: network as EvmUserOperationNetwork,
41
+ calls: [
42
+ {
43
+ to: SPEND_PERMISSION_MANAGER_ADDRESS,
44
+ data,
45
+ value: 0n,
46
+ },
47
+ ],
48
+ });
49
+ }
@@ -0,0 +1,13 @@
1
+ import type { SpendPermission, SpendPermissionNetworks } from "../../../spend-permissions/types.js";
2
+
3
+ /**
4
+ * Options for using a spend permission
5
+ */
6
+ export type UseSpendPermissionOptions = {
7
+ /** The spend permission to use */
8
+ spendPermission: SpendPermission;
9
+ /** The amount to spend (must be <= allowance) */
10
+ value: bigint;
11
+ /** The network to execute the transaction on */
12
+ network: SpendPermissionNetworks;
13
+ };
@@ -1,6 +1,7 @@
1
1
  import { encodeFunctionData, erc20Abi } from "viem";
2
2
 
3
3
  import { getErc20Address } from "./utils.js";
4
+ import { SendEvmTransactionBodyNetwork } from "../../../openapi-client/index.js";
4
5
  import { serializeEIP1559Transaction } from "../../../utils/serializeTransaction.js";
5
6
 
6
7
  import type { TransferExecutionStrategy } from "./types.js";
@@ -9,6 +10,7 @@ import type { TransactionResult } from "../sendTransaction.js";
9
10
 
10
11
  export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
11
12
  executeTransfer: async ({ apiClient, from, to, value, token, network }) => {
13
+ network = network as SendEvmTransactionBodyNetwork;
12
14
  if (token === "eth") {
13
15
  return apiClient.sendEvmTransaction(from.address, {
14
16
  transaction: serializeEIP1559Transaction({
@@ -1,11 +1,10 @@
1
- import { FundOptions } from "./fund/fund.js";
2
- import { Quote } from "./fund/Quote.js";
3
- import { QuoteFundOptions } from "./fund/quoteFund.js";
4
- import { FundOperationResult } from "./fund/types.js";
1
+ import { FundOperationResult } from "../types.js";
5
2
  import {
6
3
  WaitForFundOperationOptions,
7
4
  WaitForFundOperationResult,
8
- } from "./fund/waitForFundOperationReceipt.js";
5
+ } from "../waitForFundOperationReceipt.js";
6
+ import { EvmFundOptions } from "./fund/fund.js";
7
+ import { EvmQuoteFundOptions } from "./fund/quoteFund.js";
9
8
  import { SendUserOperationOptions, SendUserOperationReturnType } from "./sendUserOperation.js";
10
9
  import { KnownEvmNetworks } from "../../accounts/evm/types.js";
11
10
  import {
@@ -14,6 +13,8 @@ import {
14
13
  UserOperation,
15
14
  } from "../../client/evm/evm.types.js";
16
15
  import { Hex } from "../../types/misc.js";
16
+ import { EvmQuote } from "../Quote.js";
17
+ import { UseSpendPermissionOptions } from "./spend-permissions/types.js";
17
18
 
18
19
  import type { ListTokenBalancesOptions, ListTokenBalancesResult } from "./listTokenBalances.js";
19
20
  import type { RequestFaucetOptions, RequestFaucetResult } from "./requestFaucet.js";
@@ -95,7 +96,7 @@ export type Actions = {
95
96
  * });
96
97
  * ```
97
98
  */
98
- quoteFund: (options: Omit<QuoteFundOptions, "address">) => Promise<Quote>;
99
+ quoteFund: (options: Omit<EvmQuoteFundOptions, "address">) => Promise<EvmQuote>;
99
100
 
100
101
  /**
101
102
  * Funds an EVM account with the specified token amount.
@@ -118,7 +119,7 @@ export type Actions = {
118
119
  * });
119
120
  * ```
120
121
  */
121
- fund: (options: Omit<FundOptions, "address">) => Promise<FundOperationResult>;
122
+ fund: (options: Omit<EvmFundOptions, "address">) => Promise<FundOperationResult>;
122
123
 
123
124
  /**
124
125
  * Waits for a fund operation to complete and returns the transfer receipt.
@@ -353,6 +354,46 @@ export type AccountActions = Actions & {
353
354
  * ```
354
355
  */
355
356
  swap: (options: AccountSwapOptions) => Promise<AccountSwapResult>;
357
+
358
+ /**
359
+ * @deprecated Experimental! This method name will change, and is subject to other breaking changes.
360
+ *
361
+ * Uses a spend permission to execute a transaction.
362
+ * This allows the account to spend tokens that have been approved via a spend permission.
363
+ *
364
+ * @param {UseSpendPermissionOptions} options - Configuration options for using the spend permission.
365
+ * @param {SpendPermission} options.spendPermission - The spend permission object containing authorization details.
366
+ * @param {bigint} options.value - The amount to spend (must not exceed the permission's allowance).
367
+ * @param {KnownEvmNetworks} options.network - The network to execute the transaction on.
368
+ *
369
+ * @returns A promise that resolves to the transaction result.
370
+ *
371
+ * @throws {Error} If the network doesn't support spend permissions via CDP API.
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * const spendPermission = {
376
+ * account: "0x1234...", // Smart account that owns the tokens
377
+ * spender: account.address, // This account that can spend
378
+ * token: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH
379
+ * allowance: parseEther("0.01"),
380
+ * period: 86400, // 1 day
381
+ * start: 0,
382
+ * end: 281474976710655,
383
+ * salt: 0n,
384
+ * extraData: "0x",
385
+ * };
386
+ *
387
+ * const result = await account.__experimental_useSpendPermission({
388
+ * spendPermission,
389
+ * value: parseEther("0.001"), // Spend 0.001 ETH
390
+ * network: "base-sepolia",
391
+ * });
392
+ * ```
393
+ */
394
+ __experimental_useSpendPermission: (
395
+ options: UseSpendPermissionOptions,
396
+ ) => Promise<TransactionResult>;
356
397
  };
357
398
 
358
399
  export type SmartAccountActions = Actions & {
@@ -640,4 +681,44 @@ export type SmartAccountActions = Actions & {
640
681
  signTypedData: (
641
682
  options: Omit<SignTypedDataOptions, "address"> & { network: KnownEvmNetworks },
642
683
  ) => Promise<Hex>;
684
+
685
+ /**
686
+ * @deprecated Experimental! This method name will change, and is subject to other breaking changes.
687
+ *
688
+ * Uses a spend permission to execute a transaction via user operation.
689
+ * This allows the smart account to spend tokens that have been approved via a spend permission.
690
+ *
691
+ * @param {UseSpendPermissionOptions} options - Configuration options for using the spend permission.
692
+ * @param {SpendPermission} options.spendPermission - The spend permission object containing authorization details.
693
+ * @param {bigint} options.value - The amount to spend (must not exceed the permission's allowance).
694
+ * @param {KnownEvmNetworks} options.network - The network to execute the transaction on.
695
+ *
696
+ * @returns A promise that resolves to the user operation result.
697
+ *
698
+ * @throws {Error} If the network doesn't support spend permissions via CDP API.
699
+ *
700
+ * @example
701
+ * ```typescript
702
+ * const spendPermission = {
703
+ * account: "0x1234...", // Smart account that owns the tokens
704
+ * spender: smartAccount.address, // This smart account that can spend
705
+ * token: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH
706
+ * allowance: parseEther("0.01"),
707
+ * period: 86400, // 1 day
708
+ * start: 0,
709
+ * end: 281474976710655,
710
+ * salt: 0n,
711
+ * extraData: "0x",
712
+ * };
713
+ *
714
+ * const result = await smartAccount.__experimental_useSpendPermission({
715
+ * spendPermission,
716
+ * value: parseEther("0.001"), // Spend 0.001 ETH
717
+ * network: "base-sepolia",
718
+ * });
719
+ * ```
720
+ */
721
+ __experimental_useSpendPermission: (
722
+ options: UseSpendPermissionOptions,
723
+ ) => Promise<SendUserOperationReturnType>;
643
724
  };