@coinbase/cdp-sdk 1.29.0 → 1.31.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 (198) 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 +11 -0
  5. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  6. package/_cjs/accounts/evm/toEvmSmartAccount.js +11 -0
  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 +10 -0
  11. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  12. package/_cjs/accounts/solana/toSolanaAccount.js +11 -1
  13. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  14. package/_cjs/actions/evm/getUserOperation.js +1 -0
  15. package/_cjs/actions/evm/getUserOperation.js.map +1 -1
  16. package/_cjs/actions/evm/spend-permissions/account.use.js +33 -0
  17. package/_cjs/actions/evm/spend-permissions/account.use.js.map +1 -0
  18. package/_cjs/actions/evm/spend-permissions/smartAccount.use.js +35 -0
  19. package/_cjs/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
  20. package/_cjs/actions/evm/spend-permissions/types.js +3 -0
  21. package/_cjs/actions/evm/spend-permissions/types.js.map +1 -0
  22. package/_cjs/actions/solana/sendTransaction.js +1 -0
  23. package/_cjs/actions/solana/sendTransaction.js.map +1 -1
  24. package/_cjs/actions/solana/signTransaction.js +1 -0
  25. package/_cjs/actions/solana/signTransaction.js.map +1 -1
  26. package/_cjs/auth/hooks/axios/withAuth.js +3 -0
  27. package/_cjs/auth/hooks/axios/withAuth.js.map +1 -1
  28. package/_cjs/auth/utils/http.js +2 -1
  29. package/_cjs/auth/utils/http.js.map +1 -1
  30. package/_cjs/client/evm/evm.js +51 -1
  31. package/_cjs/client/evm/evm.js.map +1 -1
  32. package/_cjs/client/solana/solana.js.map +1 -1
  33. package/_cjs/index.js +5 -1
  34. package/_cjs/index.js.map +1 -1
  35. package/_cjs/openapi-client/cdpApiClient.js +37 -0
  36. package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
  37. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +29 -2
  38. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  39. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +35 -1
  40. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  41. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +160 -1
  42. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  43. package/_cjs/openapi-client/generated/index.msw.js +1 -0
  44. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  45. package/_cjs/openapi-client/generated/onramp/onramp.js +30 -0
  46. package/_cjs/openapi-client/generated/onramp/onramp.js.map +1 -0
  47. package/_cjs/openapi-client/generated/onramp/onramp.msw.js +98 -0
  48. package/_cjs/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
  49. package/_cjs/openapi-client/index.js +1 -0
  50. package/_cjs/openapi-client/index.js.map +1 -1
  51. package/_cjs/spend-permissions/constants.js +716 -0
  52. package/_cjs/spend-permissions/constants.js.map +1 -0
  53. package/_cjs/spend-permissions/types.js +3 -0
  54. package/_cjs/spend-permissions/types.js.map +1 -0
  55. package/_cjs/version.js +1 -1
  56. package/_esm/accounts/evm/networkCapabilities.js +101 -0
  57. package/_esm/accounts/evm/networkCapabilities.js.map +1 -1
  58. package/_esm/accounts/evm/toEvmServerAccount.js +11 -0
  59. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  60. package/_esm/accounts/evm/toEvmSmartAccount.js +11 -0
  61. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  62. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +10 -0
  63. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
  64. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +10 -0
  65. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  66. package/_esm/accounts/solana/toSolanaAccount.js +11 -1
  67. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  68. package/_esm/actions/evm/getUserOperation.js +1 -0
  69. package/_esm/actions/evm/getUserOperation.js.map +1 -1
  70. package/_esm/actions/evm/spend-permissions/account.use.js +30 -0
  71. package/_esm/actions/evm/spend-permissions/account.use.js.map +1 -0
  72. package/_esm/actions/evm/spend-permissions/smartAccount.use.js +32 -0
  73. package/_esm/actions/evm/spend-permissions/smartAccount.use.js.map +1 -0
  74. package/_esm/actions/evm/spend-permissions/types.js +2 -0
  75. package/_esm/actions/evm/spend-permissions/types.js.map +1 -0
  76. package/_esm/actions/solana/sendTransaction.js +1 -0
  77. package/_esm/actions/solana/sendTransaction.js.map +1 -1
  78. package/_esm/actions/solana/signTransaction.js +1 -0
  79. package/_esm/actions/solana/signTransaction.js.map +1 -1
  80. package/_esm/auth/hooks/axios/withAuth.js +3 -0
  81. package/_esm/auth/hooks/axios/withAuth.js.map +1 -1
  82. package/_esm/auth/utils/http.js +2 -1
  83. package/_esm/auth/utils/http.js.map +1 -1
  84. package/_esm/client/evm/evm.js +51 -1
  85. package/_esm/client/evm/evm.js.map +1 -1
  86. package/_esm/client/solana/solana.js +2 -2
  87. package/_esm/client/solana/solana.js.map +1 -1
  88. package/_esm/index.js +2 -1
  89. package/_esm/index.js.map +1 -1
  90. package/_esm/openapi-client/cdpApiClient.js +4 -0
  91. package/_esm/openapi-client/cdpApiClient.js.map +1 -1
  92. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +28 -1
  93. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  94. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +31 -0
  95. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  96. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +153 -0
  97. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  98. package/_esm/openapi-client/generated/index.msw.js +1 -0
  99. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  100. package/_esm/openapi-client/generated/onramp/onramp.js +25 -0
  101. package/_esm/openapi-client/generated/onramp/onramp.js.map +1 -0
  102. package/_esm/openapi-client/generated/onramp/onramp.msw.js +90 -0
  103. package/_esm/openapi-client/generated/onramp/onramp.msw.js.map +1 -0
  104. package/_esm/openapi-client/index.js +1 -0
  105. package/_esm/openapi-client/index.js.map +1 -1
  106. package/_esm/spend-permissions/constants.js +713 -0
  107. package/_esm/spend-permissions/constants.js.map +1 -0
  108. package/_esm/spend-permissions/types.js +2 -0
  109. package/_esm/spend-permissions/types.js.map +1 -0
  110. package/_esm/version.js +1 -1
  111. package/_types/accounts/evm/networkCapabilities.d.ts +101 -0
  112. package/_types/accounts/evm/networkCapabilities.d.ts.map +1 -1
  113. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  114. package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
  115. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  116. package/_types/accounts/evm/toNetworkScopedEvmServerAccount.d.ts.map +1 -1
  117. package/_types/accounts/evm/toNetworkScopedEvmSmartAccount.d.ts.map +1 -1
  118. package/_types/accounts/evm/types.d.ts +6 -0
  119. package/_types/accounts/evm/types.d.ts.map +1 -1
  120. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  121. package/_types/actions/evm/getUserOperation.d.ts.map +1 -1
  122. package/_types/actions/evm/spend-permissions/account.use.d.ts +15 -0
  123. package/_types/actions/evm/spend-permissions/account.use.d.ts.map +1 -0
  124. package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts +15 -0
  125. package/_types/actions/evm/spend-permissions/smartAccount.use.d.ts.map +1 -0
  126. package/_types/actions/evm/spend-permissions/types.d.ts +13 -0
  127. package/_types/actions/evm/spend-permissions/types.d.ts.map +1 -0
  128. package/_types/actions/evm/types.d.ts +75 -0
  129. package/_types/actions/evm/types.d.ts.map +1 -1
  130. package/_types/actions/solana/sendTransaction.d.ts +8 -2
  131. package/_types/actions/solana/sendTransaction.d.ts.map +1 -1
  132. package/_types/actions/solana/signTransaction.d.ts +8 -2
  133. package/_types/actions/solana/signTransaction.d.ts.map +1 -1
  134. package/_types/actions/solana/types.d.ts +38 -3
  135. package/_types/actions/solana/types.d.ts.map +1 -1
  136. package/_types/auth/hooks/axios/withAuth.d.ts.map +1 -1
  137. package/_types/auth/utils/http.d.ts.map +1 -1
  138. package/_types/client/evm/evm.d.ts +19 -1
  139. package/_types/client/evm/evm.d.ts.map +1 -1
  140. package/_types/client/evm/evm.types.d.ts +49 -2
  141. package/_types/client/evm/evm.types.d.ts.map +1 -1
  142. package/_types/client/solana/solana.d.ts +5 -3
  143. package/_types/client/solana/solana.d.ts.map +1 -1
  144. package/_types/index.d.ts +3 -1
  145. package/_types/index.d.ts.map +1 -1
  146. package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
  147. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +269 -5
  148. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  149. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +19 -1
  150. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  151. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +7 -1
  152. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
  153. package/_types/openapi-client/generated/index.msw.d.ts +1 -0
  154. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  155. package/_types/openapi-client/generated/onramp/onramp.d.ts +28 -0
  156. package/_types/openapi-client/generated/onramp/onramp.d.ts.map +1 -0
  157. package/_types/openapi-client/generated/onramp/onramp.msw.d.ts +8 -0
  158. package/_types/openapi-client/generated/onramp/onramp.msw.d.ts.map +1 -0
  159. package/_types/openapi-client/index.d.ts +7 -0
  160. package/_types/openapi-client/index.d.ts.map +1 -1
  161. package/_types/spend-permissions/constants.d.ts +1357 -0
  162. package/_types/spend-permissions/constants.d.ts.map +1 -0
  163. package/_types/spend-permissions/types.d.ts +30 -0
  164. package/_types/spend-permissions/types.d.ts.map +1 -0
  165. package/_types/version.d.ts +1 -1
  166. package/accounts/evm/networkCapabilities.ts +101 -0
  167. package/accounts/evm/toEvmServerAccount.ts +15 -0
  168. package/accounts/evm/toEvmSmartAccount.ts +19 -4
  169. package/accounts/evm/toNetworkScopedEvmServerAccount.ts +15 -0
  170. package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +15 -0
  171. package/accounts/evm/types.ts +18 -0
  172. package/accounts/solana/toSolanaAccount.ts +17 -3
  173. package/actions/evm/getUserOperation.ts +1 -0
  174. package/actions/evm/spend-permissions/account.use.ts +48 -0
  175. package/actions/evm/spend-permissions/smartAccount.use.ts +49 -0
  176. package/actions/evm/spend-permissions/types.ts +13 -0
  177. package/actions/evm/types.ts +81 -0
  178. package/actions/solana/sendTransaction.ts +10 -2
  179. package/actions/solana/signTransaction.ts +10 -2
  180. package/actions/solana/types.ts +44 -2
  181. package/auth/hooks/axios/withAuth.ts +3 -0
  182. package/auth/utils/http.ts +2 -1
  183. package/client/evm/evm.ts +61 -1
  184. package/client/evm/evm.types.ts +55 -0
  185. package/client/solana/solana.ts +10 -5
  186. package/index.ts +6 -1
  187. package/openapi-client/cdpApiClient.ts +5 -0
  188. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +300 -5
  189. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +203 -0
  190. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +65 -0
  191. package/openapi-client/generated/index.msw.ts +1 -0
  192. package/openapi-client/generated/onramp/onramp.msw.ts +135 -0
  193. package/openapi-client/generated/onramp/onramp.ts +54 -0
  194. package/openapi-client/index.ts +1 -0
  195. package/package.json +2 -1
  196. package/spend-permissions/constants.ts +713 -0
  197. package/spend-permissions/types.ts +42 -0
  198. package/version.ts +1 -1
@@ -62,7 +62,7 @@ export const ErrorType = {
62
62
  guest_region_forbidden: "guest_region_forbidden",
63
63
  guest_transaction_limit: "guest_transaction_limit",
64
64
  guest_transaction_count: "guest_transaction_count",
65
- guest_phone_number_verification_expired: "guest_phone_number_verification_expired",
65
+ phone_number_verification_expired: "phone_number_verification_expired",
66
66
  } as const;
67
67
 
68
68
  /**
@@ -184,6 +184,26 @@ export interface EvmCall {
184
184
  data: string;
185
185
  }
186
186
 
187
+ /**
188
+ * The revert data if the user operation has reverted.
189
+ */
190
+ export interface UserOperationReceiptRevert {
191
+ /**
192
+ * The 0x-prefixed raw hex string.
193
+ * @pattern ^0x[0-9a-fA-F]*$
194
+ */
195
+ data: string;
196
+ /** Human-readable revert reason if able to decode. */
197
+ message: string;
198
+ }
199
+
200
+ /**
201
+ * The receipt that contains information about the execution of user operation.
202
+ */
203
+ export interface UserOperationReceipt {
204
+ revert?: UserOperationReceiptRevert;
205
+ }
206
+
187
207
  /**
188
208
  * The status of the user operation.
189
209
  */
@@ -216,6 +236,96 @@ export interface EvmUserOperation {
216
236
  * @pattern ^0x[0-9a-fA-F]{64}$|^$
217
237
  */
218
238
  transactionHash?: string;
239
+ /** The list of receipts associated with the user operation. */
240
+ receipts?: UserOperationReceipt[];
241
+ }
242
+
243
+ export interface CreateSpendPermissionRequest {
244
+ /** The network of the spend permission. */
245
+ network: string;
246
+ /**
247
+ * Smart account this spend permission is valid for.
248
+ * @pattern ^0x[a-fA-F0-9]{40}$
249
+ */
250
+ account: string;
251
+ /**
252
+ * Entity that can spend account's tokens.
253
+ * @pattern ^0x[a-fA-F0-9]{40}$
254
+ */
255
+ spender: string;
256
+ /**
257
+ * Token address (ERC-7528 native token address or ERC-20 contract).
258
+ * @pattern ^0x[a-fA-F0-9]{40}$
259
+ */
260
+ token: string;
261
+ /** Maximum allowed value to spend, in atomic units for the specified token, within each period. */
262
+ allowance: string;
263
+ /** Time duration for resetting used allowance on a recurring basis (seconds). */
264
+ period: string;
265
+ /** The start time for this spend permission, in Unix seconds. */
266
+ start: string;
267
+ /** The expiration time for this spend permission, in Unix seconds. */
268
+ end: string;
269
+ /** An arbitrary salt to differentiate unique spend permissions with otherwise identical data. */
270
+ salt?: string;
271
+ /** Arbitrary data to include in the permission. */
272
+ extraData?: string;
273
+ /** The paymaster URL of the spend permission. */
274
+ paymasterUrl?: string;
275
+ }
276
+
277
+ /**
278
+ * The core spend permission.
279
+ */
280
+ export interface SpendPermission {
281
+ /**
282
+ * Smart account this spend permission is valid for.
283
+ * @pattern ^0x[a-fA-F0-9]{40}$
284
+ */
285
+ account: string;
286
+ /**
287
+ * Entity that can spend account's tokens.
288
+ * @pattern ^0x[a-fA-F0-9]{40}$
289
+ */
290
+ spender: string;
291
+ /**
292
+ * Token address (ERC-7528 native token address or ERC-20 contract).
293
+ * @pattern ^0x[a-fA-F0-9]{40}$
294
+ */
295
+ token: string;
296
+ /** Maximum allowed value to spend, in atomic units for the specified token, within each period. */
297
+ allowance: string;
298
+ /** Time duration for resetting used allowance on a recurring basis (seconds). */
299
+ period?: string;
300
+ /** The start time for this spend permission, in Unix seconds. */
301
+ start?: string;
302
+ /** The expiration time for this spend permission, in Unix seconds. */
303
+ end?: string;
304
+ /** An arbitrary salt to differentiate unique spend permissions with otherwise identical data. */
305
+ salt?: string;
306
+ /** Arbitrary data to include in the permission. */
307
+ extraData?: string;
308
+ }
309
+
310
+ export interface SpendPermissionResponseObject {
311
+ permission?: SpendPermission;
312
+ /** Unique hash identifier for this permission. */
313
+ permissionHash?: string;
314
+ /** Whether this permission has been revoked. */
315
+ revoked?: boolean;
316
+ /** The UTC ISO 8601 timestamp when the permission was revoked (if applicable). */
317
+ revokedAt?: string;
318
+ /** The UTC ISO 8601 timestamp when the permission was created. */
319
+ createdAt?: string;
320
+ }
321
+
322
+ export interface RevokeSpendPermissionRequest {
323
+ /** The network of the spend permission. */
324
+ network: string;
325
+ /** The hash of the spend permission to revoke. */
326
+ permissionHash: string;
327
+ /** The paymaster URL of the spend permission. */
328
+ paymasterUrl?: string;
219
329
  }
220
330
 
221
331
  /**
@@ -227,6 +337,8 @@ export type EvmSwapsNetwork = (typeof EvmSwapsNetwork)[keyof typeof EvmSwapsNetw
227
337
  export const EvmSwapsNetwork = {
228
338
  base: "base",
229
339
  ethereum: "ethereum",
340
+ arbitrum: "arbitrum",
341
+ optimism: "optimism",
230
342
  } as const;
231
343
 
232
344
  /**
@@ -1206,7 +1318,7 @@ export const SolAddressCriterionType = {
1206
1318
  } as const;
1207
1319
 
1208
1320
  /**
1209
- * The operator to use for the comparison. Each of the addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the addresses field will be on the right-hand side.
1321
+ * The operator to use for the comparison. Each of the native transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side.
1210
1322
  */
1211
1323
  export type SolAddressCriterionOperator =
1212
1324
  (typeof SolAddressCriterionOperator)[keyof typeof SolAddressCriterionOperator];
@@ -1218,14 +1330,14 @@ export const SolAddressCriterionOperator = {
1218
1330
  } as const;
1219
1331
 
1220
1332
  /**
1221
- * The criterion for the recipient addresses of a Solana transaction.
1333
+ * The criterion for the recipient addresses of a Solana transaction's native transfer instruction.
1222
1334
  */
1223
1335
  export interface SolAddressCriterion {
1224
1336
  /** The type of criterion to use. This should be `solAddress`. */
1225
1337
  type: SolAddressCriterionType;
1226
- /** The Solana addresses that are compared to the list of addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array. */
1338
+ /** The Solana addresses that are compared to the list of native transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array. */
1227
1339
  addresses: string[];
1228
- /** The operator to use for the comparison. Each of the addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the addresses field will be on the right-hand side. */
1340
+ /** The operator to use for the comparison. Each of the native transfer recipient addresses in the transaction's `accountKeys` (for legacy transactions) or `staticAccountKeys` (for V0 transactions) array will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
1229
1341
  operator: SolAddressCriterionOperator;
1230
1342
  }
1231
1343
 
@@ -1728,6 +1840,110 @@ export interface Transfer {
1728
1840
  transactionHash?: string;
1729
1841
  }
1730
1842
 
1843
+ /**
1844
+ * The type of payment method to be used to complete the order.
1845
+ */
1846
+ export type OnrampPaymentMethodTypeId =
1847
+ (typeof OnrampPaymentMethodTypeId)[keyof typeof OnrampPaymentMethodTypeId];
1848
+
1849
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
1850
+ export const OnrampPaymentMethodTypeId = {
1851
+ GUEST_CHECKOUT_APPLE_PAY: "GUEST_CHECKOUT_APPLE_PAY",
1852
+ } as const;
1853
+
1854
+ /**
1855
+ * The type of fee.
1856
+ */
1857
+ export type OnrampOrderFeeType = (typeof OnrampOrderFeeType)[keyof typeof OnrampOrderFeeType];
1858
+
1859
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
1860
+ export const OnrampOrderFeeType = {
1861
+ FEE_TYPE_NETWORK: "FEE_TYPE_NETWORK",
1862
+ FEE_TYPE_EXCHANGE: "FEE_TYPE_EXCHANGE",
1863
+ } as const;
1864
+
1865
+ /**
1866
+ * A fee associated with an order.
1867
+ */
1868
+ export interface OnrampOrderFee {
1869
+ /** The type of fee. */
1870
+ type: OnrampOrderFeeType;
1871
+ /** The amount of the fee. */
1872
+ amount: string;
1873
+ /** The currency of the fee. */
1874
+ currency: string;
1875
+ }
1876
+
1877
+ /**
1878
+ * The status of an onramp order.
1879
+ */
1880
+ export type OnrampOrderStatus = (typeof OnrampOrderStatus)[keyof typeof OnrampOrderStatus];
1881
+
1882
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
1883
+ export const OnrampOrderStatus = {
1884
+ ONRAMP_ORDER_STATUS_PENDING_AUTH: "ONRAMP_ORDER_STATUS_PENDING_AUTH",
1885
+ ONRAMP_ORDER_STATUS_PENDING_PAYMENT: "ONRAMP_ORDER_STATUS_PENDING_PAYMENT",
1886
+ ONRAMP_ORDER_STATUS_PROCESSING: "ONRAMP_ORDER_STATUS_PROCESSING",
1887
+ ONRAMP_ORDER_STATUS_COMPLETED: "ONRAMP_ORDER_STATUS_COMPLETED",
1888
+ ONRAMP_ORDER_STATUS_FAILED: "ONRAMP_ORDER_STATUS_FAILED",
1889
+ } as const;
1890
+
1891
+ /**
1892
+ * An Onramp order.
1893
+ */
1894
+ export interface OnrampOrder {
1895
+ /** The ID of the onramp order. */
1896
+ orderId: string;
1897
+ /** The total amount of fiat to be paid, inclusive of any fees. */
1898
+ paymentTotal: string;
1899
+ /** The amount of fiat to be converted to crypto. */
1900
+ paymentSubtotal: string;
1901
+ /** The fiat currency to be converted to crypto. */
1902
+ paymentCurrency: string;
1903
+ paymentMethod: OnrampPaymentMethodTypeId;
1904
+ /** The amount of crypto to be purchased. */
1905
+ purchaseAmount: string;
1906
+ /** The crypto currency to be purchased. */
1907
+ purchaseCurrency: string;
1908
+ /** The fees associated with the order. */
1909
+ fees: OnrampOrderFee[];
1910
+ /** The exchange rate used to convert fiat to crypto i.e. the crypto value of one fiat. */
1911
+ exchangeRate: string;
1912
+ /** The destination address to send the crypto to. */
1913
+ destinationAddress: string;
1914
+ /** The network to send the crypto on. */
1915
+ destinationNetwork: string;
1916
+ status: OnrampOrderStatus;
1917
+ /** The transaction hash of the order (only available once crypto has been sent). */
1918
+ txHash?: string;
1919
+ /** The date and time the order was created. */
1920
+ createdAt: string;
1921
+ /** The date and time the order was last updated. */
1922
+ updatedAt: string;
1923
+ }
1924
+
1925
+ /**
1926
+ * The type of payment link.
1927
+ */
1928
+ export type OnrampPaymentLinkType =
1929
+ (typeof OnrampPaymentLinkType)[keyof typeof OnrampPaymentLinkType];
1930
+
1931
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
1932
+ export const OnrampPaymentLinkType = {
1933
+ PAYMENT_LINK_TYPE_APPLE_PAY_BUTTON: "PAYMENT_LINK_TYPE_APPLE_PAY_BUTTON",
1934
+ } as const;
1935
+
1936
+ /**
1937
+ * A payment link to pay for an order.
1938
+
1939
+ Please refer to the [Onramp docs](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/onramp-overview) for details on how to integrate with the different payment link types.
1940
+ */
1941
+ export interface OnrampPaymentLink {
1942
+ /** The URL to the hosted widget the user should be redirected to. For certain payment link types you can append your own redirect_url query parameter to this URL to ensure the user is redirected back to your app after the widget completes. */
1943
+ url: string;
1944
+ paymentLinkType: OnrampPaymentLinkType;
1945
+ }
1946
+
1731
1947
  /**
1732
1948
  * Internal server error.
1733
1949
  */
@@ -1758,6 +1974,16 @@ export type IdempotencyErrorResponse = Error;
1758
1974
  */
1759
1975
  export type AlreadyExistsErrorResponse = Error;
1760
1976
 
1977
+ /**
1978
+ * Unauthorized.
1979
+ */
1980
+ export type UnauthorizedErrorResponse = Error;
1981
+
1982
+ /**
1983
+ * Rate limit exceeded.
1984
+ */
1985
+ export type RateLimitExceededResponse = Error;
1986
+
1761
1987
  /**
1762
1988
  * A JWT signed using your Wallet Secret, encoded in base64. Refer to the
1763
1989
  [Generate Wallet Token](https://docs.cdp.coinbase.com/api-reference/v2/authentication#2-generate-wallet-token)
@@ -1834,6 +2060,10 @@ export const SendEvmTransactionBodyNetwork = {
1834
2060
  "base-sepolia": "base-sepolia",
1835
2061
  ethereum: "ethereum",
1836
2062
  "ethereum-sepolia": "ethereum-sepolia",
2063
+ avalanche: "avalanche",
2064
+ polygon: "polygon",
2065
+ optimism: "optimism",
2066
+ arbitrum: "arbitrum",
1837
2067
  } as const;
1838
2068
 
1839
2069
  export type SendEvmTransactionBody = {
@@ -1973,6 +2203,24 @@ export type SendUserOperationBody = {
1973
2203
  signature: string;
1974
2204
  };
1975
2205
 
2206
+ export type ListSpendPermissionsParams = {
2207
+ /**
2208
+ * The number of spend permissions to return per page.
2209
+ */
2210
+ pageSize?: number;
2211
+ /**
2212
+ * The token for the next page of spend permissions. Will be empty if there are no more spend permissions to fetch.
2213
+ */
2214
+ pageToken?: string;
2215
+ };
2216
+
2217
+ export type ListSpendPermissions200AllOf = {
2218
+ /** The spend permissions for the smart account. */
2219
+ spendPermissions: SpendPermissionResponseObject[];
2220
+ };
2221
+
2222
+ export type ListSpendPermissions200 = ListSpendPermissions200AllOf & ListResponse;
2223
+
1976
2224
  export type GetEvmSwapPriceParams = {
1977
2225
  network: EvmSwapsNetwork;
1978
2226
  toToken: ToToken;
@@ -2368,3 +2616,50 @@ export type CreatePaymentTransferQuoteBody = {
2368
2616
  export type CreatePaymentTransferQuote201 = {
2369
2617
  transfer: Transfer;
2370
2618
  };
2619
+
2620
+ export type CreateOnrampOrderBody = {
2621
+ /** The timestamp of when the user acknowledged that by using Coinbase Onramp they are accepting the Coinbase Terms (https://www.coinbase.com/legal/guest-checkout/us), User Agreement (https://www.coinbase.com/legal/user_agreement), and Privacy Policy (https://www.coinbase.com/legal/privacy). */
2622
+ agreementAcceptedAt: string;
2623
+ /** The address the purchased crypto will be sent to. */
2624
+ destinationAddress: string;
2625
+ /** The name of the crypto network the purchased currency will be sent on.
2626
+
2627
+ Use the [Onramp Buy Options API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-buy-options) to discover the supported networks for your user's location. */
2628
+ destinationNetwork: string;
2629
+ /** The verified email address of the user requesting the onramp transaction. This email must be verified by your app (via OTP) before being used with the Onramp API. */
2630
+ email: string;
2631
+ /** If true, this API will return a quote without creating any transaction. */
2632
+ isQuote?: boolean;
2633
+ /** Optional partner order reference ID. */
2634
+ partnerOrderRef?: string;
2635
+ /** A unique string that represents the user in your app. This can be used to link individual transactions together so you can retrieve the transaction history for your users. Prefix this string with “sandbox-” (e.g. "sandbox-user-1234") to perform a sandbox transaction which will allow you to test your integration without any real transfer of funds.
2636
+
2637
+ This value can be used with with [Onramp User Transactions API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-onramp-transactions-by-id) to retrieve all transactions created by the user. */
2638
+ partnerUserRef: string;
2639
+ /** A string representing the amount of fiat the user wishes to pay in exchange for crypto. When using this parameter, the returned quote will be inclusive of fees i.e. the user will pay this exact amount of the payment currency. */
2640
+ paymentAmount?: string;
2641
+ /** The fiat currency to be converted to crypto. */
2642
+ paymentCurrency: string;
2643
+ paymentMethod: OnrampPaymentMethodTypeId;
2644
+ /** The phone number of the user requesting the onramp transaction in E.164 format. This phone number must be verified by your app (via OTP) before being used with the Onramp API.
2645
+
2646
+ Please refer to the [Onramp docs](https://docs.cdp.coinbase.com/onramp-&-offramp/onramp-apis/apple-pay-onramp-api) for more details on phone number verification requirements and best practices. */
2647
+ phoneNumber: string;
2648
+ /** Timestamp of when the user's phone number was verified via OTP. User phone number must be verified every 60 days. If this timestamp is older than 60 days, an error will be returned. */
2649
+ phoneNumberVerifiedAt: string;
2650
+ /** A string representing the amount of crypto the user wishes to purchase. When using this parameter the returned quote will be exclusive of fees i.e. the user will receive this exact amount of the purchase currency. */
2651
+ purchaseAmount?: string;
2652
+ /** The ticker (e.g. `BTC`, `USDC`, `SOL`) or the Coinbase UUID (e.g. `d85dce9b-5b73-5c3c-8978-522ce1d1c1b4`) of the crypto asset to be purchased.
2653
+
2654
+ Use the [Onramp Buy Options API](https://docs.cdp.coinbase.com/api-reference/rest-api/onramp-offramp/get-buy-options) to discover the supported purchase currencies for your user's location. */
2655
+ purchaseCurrency: string;
2656
+ };
2657
+
2658
+ export type CreateOnrampOrder201 = {
2659
+ order: OnrampOrder;
2660
+ paymentLink?: OnrampPaymentLink;
2661
+ };
2662
+
2663
+ export type GetOnrampOrderById200 = {
2664
+ order: OnrampOrder;
2665
+ };
@@ -14,6 +14,7 @@ import type {
14
14
  EvmSmartAccount,
15
15
  EvmUserOperation,
16
16
  ListEvmSmartAccounts200,
17
+ ListSpendPermissions200,
17
18
  } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
18
19
 
19
20
  export const getListEvmSmartAccountsResponseMock = (): ListEvmSmartAccounts200 => ({
@@ -192,6 +193,15 @@ export const getPrepareUserOperationResponseMock = (
192
193
  faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
193
194
  undefined,
194
195
  ]),
196
+ receipts: faker.helpers.arrayElement([
197
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
198
+ revert: faker.helpers.arrayElement([
199
+ { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
200
+ undefined,
201
+ ]),
202
+ })),
203
+ undefined,
204
+ ]),
195
205
  ...overrideResponse,
196
206
  });
197
207
 
@@ -217,6 +227,15 @@ export const getGetUserOperationResponseMock = (
217
227
  faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
218
228
  undefined,
219
229
  ]),
230
+ receipts: faker.helpers.arrayElement([
231
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
232
+ revert: faker.helpers.arrayElement([
233
+ { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
234
+ undefined,
235
+ ]),
236
+ })),
237
+ undefined,
238
+ ]),
220
239
  ...overrideResponse,
221
240
  });
222
241
 
@@ -242,6 +261,118 @@ export const getSendUserOperationResponseMock = (
242
261
  faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
243
262
  undefined,
244
263
  ]),
264
+ receipts: faker.helpers.arrayElement([
265
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
266
+ revert: faker.helpers.arrayElement([
267
+ { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
268
+ undefined,
269
+ ]),
270
+ })),
271
+ undefined,
272
+ ]),
273
+ ...overrideResponse,
274
+ });
275
+
276
+ export const getCreateSpendPermissionResponseMock = (
277
+ overrideResponse: Partial<EvmUserOperation> = {},
278
+ ): EvmUserOperation => ({
279
+ network: faker.helpers.arrayElement(Object.values(EvmUserOperationNetwork)),
280
+ userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
281
+ calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
282
+ to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
283
+ value: faker.string.alpha(20),
284
+ data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"),
285
+ })),
286
+ status: faker.helpers.arrayElement([
287
+ "pending",
288
+ "signed",
289
+ "broadcast",
290
+ "complete",
291
+ "dropped",
292
+ "failed",
293
+ ] as const),
294
+ transactionHash: faker.helpers.arrayElement([
295
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
296
+ undefined,
297
+ ]),
298
+ receipts: faker.helpers.arrayElement([
299
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
300
+ revert: faker.helpers.arrayElement([
301
+ { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
302
+ undefined,
303
+ ]),
304
+ })),
305
+ undefined,
306
+ ]),
307
+ ...overrideResponse,
308
+ });
309
+
310
+ export const getListSpendPermissionsResponseMock = (): ListSpendPermissions200 => ({
311
+ ...{
312
+ spendPermissions: Array.from(
313
+ { length: faker.number.int({ min: 1, max: 10 }) },
314
+ (_, i) => i + 1,
315
+ ).map(() => ({
316
+ permission: faker.helpers.arrayElement([
317
+ {
318
+ account: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
319
+ spender: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
320
+ token: faker.helpers.fromRegExp("^0x[a-fA-F0-9]{40}$"),
321
+ allowance: faker.string.alpha(20),
322
+ period: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
323
+ start: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
324
+ end: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
325
+ salt: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
326
+ extraData: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
327
+ },
328
+ undefined,
329
+ ]),
330
+ permissionHash: faker.helpers.arrayElement([faker.string.alpha(20), undefined]),
331
+ revoked: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
332
+ revokedAt: faker.helpers.arrayElement([
333
+ `${faker.date.past().toISOString().split(".")[0]}Z`,
334
+ undefined,
335
+ ]),
336
+ createdAt: faker.helpers.arrayElement([
337
+ `${faker.date.past().toISOString().split(".")[0]}Z`,
338
+ undefined,
339
+ ]),
340
+ })),
341
+ },
342
+ ...{ nextPageToken: faker.helpers.arrayElement([faker.string.alpha(20), undefined]) },
343
+ });
344
+
345
+ export const getRevokeSpendPermissionResponseMock = (
346
+ overrideResponse: Partial<EvmUserOperation> = {},
347
+ ): EvmUserOperation => ({
348
+ network: faker.helpers.arrayElement(Object.values(EvmUserOperationNetwork)),
349
+ userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
350
+ calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
351
+ to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
352
+ value: faker.string.alpha(20),
353
+ data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"),
354
+ })),
355
+ status: faker.helpers.arrayElement([
356
+ "pending",
357
+ "signed",
358
+ "broadcast",
359
+ "complete",
360
+ "dropped",
361
+ "failed",
362
+ ] as const),
363
+ transactionHash: faker.helpers.arrayElement([
364
+ faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$|^$"),
365
+ undefined,
366
+ ]),
367
+ receipts: faker.helpers.arrayElement([
368
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
369
+ revert: faker.helpers.arrayElement([
370
+ { data: faker.helpers.fromRegExp("^0x[0-9a-fA-F]*$"), message: faker.string.alpha(20) },
371
+ undefined,
372
+ ]),
373
+ })),
374
+ undefined,
375
+ ]),
245
376
  ...overrideResponse,
246
377
  });
247
378
 
@@ -431,6 +562,75 @@ export const getSendUserOperationMockHandler = (
431
562
  },
432
563
  );
433
564
  };
565
+
566
+ export const getCreateSpendPermissionMockHandler = (
567
+ overrideResponse?:
568
+ | EvmUserOperation
569
+ | ((
570
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
571
+ ) => Promise<EvmUserOperation> | EvmUserOperation),
572
+ ) => {
573
+ return http.post("*/v2/evm/smart-accounts/:address/spend-permissions", async info => {
574
+ await delay(0);
575
+
576
+ return new HttpResponse(
577
+ JSON.stringify(
578
+ overrideResponse !== undefined
579
+ ? typeof overrideResponse === "function"
580
+ ? await overrideResponse(info)
581
+ : overrideResponse
582
+ : getCreateSpendPermissionResponseMock(),
583
+ ),
584
+ { status: 200, headers: { "Content-Type": "application/json" } },
585
+ );
586
+ });
587
+ };
588
+
589
+ export const getListSpendPermissionsMockHandler = (
590
+ overrideResponse?:
591
+ | ListSpendPermissions200
592
+ | ((
593
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
594
+ ) => Promise<ListSpendPermissions200> | ListSpendPermissions200),
595
+ ) => {
596
+ return http.get("*/v2/evm/smart-accounts/:address/spend-permissions/list", async info => {
597
+ await delay(0);
598
+
599
+ return new HttpResponse(
600
+ JSON.stringify(
601
+ overrideResponse !== undefined
602
+ ? typeof overrideResponse === "function"
603
+ ? await overrideResponse(info)
604
+ : overrideResponse
605
+ : getListSpendPermissionsResponseMock(),
606
+ ),
607
+ { status: 200, headers: { "Content-Type": "application/json" } },
608
+ );
609
+ });
610
+ };
611
+
612
+ export const getRevokeSpendPermissionMockHandler = (
613
+ overrideResponse?:
614
+ | EvmUserOperation
615
+ | ((
616
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
617
+ ) => Promise<EvmUserOperation> | EvmUserOperation),
618
+ ) => {
619
+ return http.post("*/v2/evm/smart-accounts/:address/spend-permissions/revoke", async info => {
620
+ await delay(0);
621
+
622
+ return new HttpResponse(
623
+ JSON.stringify(
624
+ overrideResponse !== undefined
625
+ ? typeof overrideResponse === "function"
626
+ ? await overrideResponse(info)
627
+ : overrideResponse
628
+ : getRevokeSpendPermissionResponseMock(),
629
+ ),
630
+ { status: 200, headers: { "Content-Type": "application/json" } },
631
+ );
632
+ });
633
+ };
434
634
  export const getEvmSmartAccountsMock = () => [
435
635
  getListEvmSmartAccountsMockHandler(),
436
636
  getCreateEvmSmartAccountMockHandler(),
@@ -440,4 +640,7 @@ export const getEvmSmartAccountsMock = () => [
440
640
  getPrepareUserOperationMockHandler(),
441
641
  getGetUserOperationMockHandler(),
442
642
  getSendUserOperationMockHandler(),
643
+ getCreateSpendPermissionMockHandler(),
644
+ getListSpendPermissionsMockHandler(),
645
+ getRevokeSpendPermissionMockHandler(),
443
646
  ];