@coinbase/cdp-sdk 1.6.0 → 1.8.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 (257) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +284 -1
  3. package/_cjs/accounts/evm/toEvmServerAccount.js +4 -2
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  5. package/_cjs/accounts/evm/toEvmSmartAccount.js +7 -0
  6. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  7. package/_cjs/accounts/evm/types.js.map +1 -0
  8. package/_cjs/accounts/solana/toSolanaAccount.js +42 -0
  9. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -0
  10. package/_cjs/accounts/solana/types.js +3 -0
  11. package/_cjs/accounts/solana/types.js.map +1 -0
  12. package/_cjs/actions/evm/getUserOperation.js +36 -0
  13. package/_cjs/actions/evm/getUserOperation.js.map +1 -0
  14. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +11 -7
  15. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  16. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +9 -6
  17. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  18. package/_cjs/actions/evm/transfer/transfer.js +7 -3
  19. package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
  20. package/_cjs/actions/solana/requestFaucet.js +29 -0
  21. package/_cjs/actions/solana/requestFaucet.js.map +1 -0
  22. package/_cjs/actions/solana/signMessage.js +29 -0
  23. package/_cjs/actions/solana/signMessage.js.map +1 -0
  24. package/_cjs/actions/solana/signTransaction.js +46 -0
  25. package/_cjs/actions/solana/signTransaction.js.map +1 -0
  26. package/_cjs/actions/solana/types.js +3 -0
  27. package/_cjs/actions/solana/types.js.map +1 -0
  28. package/_cjs/analytics.js +68 -8
  29. package/_cjs/analytics.js.map +1 -1
  30. package/_cjs/client/cdp.js +9 -3
  31. package/_cjs/client/cdp.js.map +1 -1
  32. package/_cjs/client/evm/evm.js +135 -27
  33. package/_cjs/client/evm/evm.js.map +1 -1
  34. package/_cjs/client/policies/index.js +6 -0
  35. package/_cjs/client/policies/index.js.map +1 -0
  36. package/_cjs/client/policies/policies.js +232 -0
  37. package/_cjs/client/policies/policies.js.map +1 -0
  38. package/_cjs/client/policies/policies.types.js +3 -0
  39. package/_cjs/client/policies/policies.types.js.map +1 -0
  40. package/_cjs/client/solana/solana.js +84 -22
  41. package/_cjs/client/solana/solana.js.map +1 -1
  42. package/_cjs/index.js +4 -1
  43. package/_cjs/index.js.map +1 -1
  44. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +59 -1
  45. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  46. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +27 -1
  47. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  48. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +56 -1
  49. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  50. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  51. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  52. package/_cjs/openapi-client/generated/index.msw.js +3 -2
  53. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  54. package/_cjs/openapi-client/generated/policy-engine/policy-engine.js +56 -0
  55. package/_cjs/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
  56. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +284 -0
  57. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
  58. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js +14 -1
  59. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  60. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +42 -1
  61. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  62. package/_cjs/openapi-client/index.js +7 -1
  63. package/_cjs/openapi-client/index.js.map +1 -1
  64. package/_cjs/policies/schema.js +186 -0
  65. package/_cjs/policies/schema.js.map +1 -0
  66. package/_cjs/policies/types.js +3 -0
  67. package/_cjs/{accounts → policies}/types.js.map +1 -1
  68. package/_cjs/version.js +1 -1
  69. package/_esm/accounts/evm/toEvmServerAccount.js +4 -2
  70. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  71. package/_esm/accounts/evm/toEvmSmartAccount.js +7 -0
  72. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  73. package/_esm/accounts/evm/types.js.map +1 -0
  74. package/_esm/accounts/solana/toSolanaAccount.js +39 -0
  75. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -0
  76. package/_esm/accounts/solana/types.js +2 -0
  77. package/_esm/accounts/solana/types.js.map +1 -0
  78. package/_esm/actions/evm/getUserOperation.js +33 -0
  79. package/_esm/actions/evm/getUserOperation.js.map +1 -0
  80. package/_esm/actions/evm/transfer/accountTransferStrategy.js +11 -7
  81. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  82. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +9 -6
  83. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  84. package/_esm/actions/evm/transfer/transfer.js +7 -3
  85. package/_esm/actions/evm/transfer/transfer.js.map +1 -1
  86. package/_esm/actions/solana/requestFaucet.js +26 -0
  87. package/_esm/actions/solana/requestFaucet.js.map +1 -0
  88. package/_esm/actions/solana/signMessage.js +26 -0
  89. package/_esm/actions/solana/signMessage.js.map +1 -0
  90. package/_esm/actions/solana/signTransaction.js +43 -0
  91. package/_esm/actions/solana/signTransaction.js.map +1 -0
  92. package/_esm/actions/solana/types.js +2 -0
  93. package/_esm/actions/solana/types.js.map +1 -0
  94. package/_esm/analytics.js +68 -7
  95. package/_esm/analytics.js.map +1 -1
  96. package/_esm/client/cdp.js +10 -4
  97. package/_esm/client/cdp.js.map +1 -1
  98. package/_esm/client/evm/evm.js +135 -27
  99. package/_esm/client/evm/evm.js.map +1 -1
  100. package/_esm/client/policies/index.js +2 -0
  101. package/_esm/client/policies/index.js.map +1 -0
  102. package/_esm/client/policies/policies.js +228 -0
  103. package/_esm/client/policies/policies.js.map +1 -0
  104. package/_esm/client/policies/policies.types.js +2 -0
  105. package/_esm/client/policies/policies.types.js.map +1 -0
  106. package/_esm/client/solana/solana.js +84 -22
  107. package/_esm/client/solana/solana.js.map +1 -1
  108. package/_esm/index.js +1 -0
  109. package/_esm/index.js.map +1 -1
  110. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +58 -0
  111. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  112. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +24 -0
  113. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  114. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +51 -0
  115. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  116. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  117. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  118. package/_esm/openapi-client/generated/index.msw.js +3 -2
  119. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  120. package/_esm/openapi-client/generated/policy-engine/policy-engine.js +48 -0
  121. package/_esm/openapi-client/generated/policy-engine/policy-engine.js.map +1 -0
  122. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +259 -0
  123. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -0
  124. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +12 -0
  125. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  126. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +39 -0
  127. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  128. package/_esm/openapi-client/index.js +6 -0
  129. package/_esm/openapi-client/index.js.map +1 -1
  130. package/_esm/policies/schema.js +183 -0
  131. package/_esm/policies/schema.js.map +1 -0
  132. package/_esm/policies/types.js +2 -0
  133. package/_esm/{accounts → policies}/types.js.map +1 -1
  134. package/_esm/version.js +1 -1
  135. package/_types/accounts/evm/toEvmServerAccount.d.ts +1 -1
  136. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  137. package/_types/accounts/evm/toEvmSmartAccount.d.ts +1 -1
  138. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  139. package/_types/accounts/{types.d.ts → evm/types.d.ts} +10 -7
  140. package/_types/accounts/evm/types.d.ts.map +1 -0
  141. package/_types/accounts/solana/toSolanaAccount.d.ts +20 -0
  142. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -0
  143. package/_types/accounts/solana/types.d.ts +12 -0
  144. package/_types/accounts/solana/types.d.ts.map +1 -0
  145. package/_types/actions/evm/getUserOperation.d.ts +22 -0
  146. package/_types/actions/evm/getUserOperation.d.ts.map +1 -0
  147. package/_types/actions/evm/sendUserOperation.d.ts +1 -1
  148. package/_types/actions/evm/sendUserOperation.d.ts.map +1 -1
  149. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +1 -1
  150. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  151. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +1 -1
  152. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
  153. package/_types/actions/evm/transfer/transfer.d.ts +3 -3
  154. package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
  155. package/_types/actions/evm/transfer/types.d.ts +39 -6
  156. package/_types/actions/evm/transfer/types.d.ts.map +1 -1
  157. package/_types/actions/evm/types.d.ts +28 -5
  158. package/_types/actions/evm/types.d.ts.map +1 -1
  159. package/_types/actions/solana/requestFaucet.d.ts +23 -0
  160. package/_types/actions/solana/requestFaucet.d.ts.map +1 -0
  161. package/_types/actions/solana/signMessage.d.ts +23 -0
  162. package/_types/actions/solana/signMessage.d.ts.map +1 -0
  163. package/_types/actions/solana/signTransaction.d.ts +38 -0
  164. package/_types/actions/solana/signTransaction.d.ts.map +1 -0
  165. package/_types/actions/solana/types.d.ts +80 -0
  166. package/_types/actions/solana/types.d.ts.map +1 -0
  167. package/_types/analytics.d.ts +14 -5
  168. package/_types/analytics.d.ts.map +1 -1
  169. package/_types/client/cdp.d.ts +3 -0
  170. package/_types/client/cdp.d.ts.map +1 -1
  171. package/_types/client/evm/evm.d.ts +89 -1
  172. package/_types/client/evm/evm.d.ts.map +1 -1
  173. package/_types/client/evm/evm.types.d.ts +36 -6
  174. package/_types/client/evm/evm.types.d.ts.map +1 -1
  175. package/_types/client/policies/index.d.ts +2 -0
  176. package/_types/client/policies/index.d.ts.map +1 -0
  177. package/_types/client/policies/policies.d.ts +216 -0
  178. package/_types/client/policies/policies.d.ts.map +1 -0
  179. package/_types/client/policies/policies.types.d.ts +96 -0
  180. package/_types/client/policies/policies.types.d.ts.map +1 -0
  181. package/_types/client/solana/solana.d.ts +47 -4
  182. package/_types/client/solana/solana.d.ts.map +1 -1
  183. package/_types/client/solana/solana.types.d.ts +21 -12
  184. package/_types/client/solana/solana.types.d.ts.map +1 -1
  185. package/_types/index.d.ts +3 -1
  186. package/_types/index.d.ts.map +1 -1
  187. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +299 -0
  188. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  189. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -1
  190. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  191. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -1
  192. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
  193. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +3 -1
  194. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  195. package/_types/openapi-client/generated/index.msw.d.ts +3 -2
  196. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  197. package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts +43 -0
  198. package/_types/openapi-client/generated/policy-engine/policy-engine.d.ts.map +1 -0
  199. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +25 -0
  200. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -0
  201. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +7 -1
  202. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
  203. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +2 -0
  204. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
  205. package/_types/openapi-client/index.d.ts +19 -0
  206. package/_types/openapi-client/index.d.ts.map +1 -1
  207. package/_types/policies/schema.d.ts +922 -0
  208. package/_types/policies/schema.d.ts.map +1 -0
  209. package/_types/policies/types.d.ts +19 -0
  210. package/_types/policies/types.d.ts.map +1 -0
  211. package/_types/types/misc.d.ts +39 -0
  212. package/_types/types/misc.d.ts.map +1 -1
  213. package/_types/version.d.ts +1 -1
  214. package/accounts/evm/toEvmServerAccount.ts +7 -4
  215. package/accounts/evm/toEvmSmartAccount.ts +11 -1
  216. package/accounts/{types.ts → evm/types.ts} +10 -12
  217. package/accounts/solana/toSolanaAccount.ts +60 -0
  218. package/accounts/solana/types.ts +13 -0
  219. package/actions/evm/getUserOperation.ts +40 -0
  220. package/actions/evm/sendUserOperation.ts +1 -1
  221. package/actions/evm/transfer/accountTransferStrategy.ts +12 -8
  222. package/actions/evm/transfer/smartAccountTransferStrategy.ts +10 -7
  223. package/actions/evm/transfer/transfer.ts +17 -6
  224. package/actions/evm/transfer/types.ts +54 -11
  225. package/actions/evm/types.ts +37 -5
  226. package/actions/solana/requestFaucet.ts +35 -0
  227. package/actions/solana/signMessage.ts +36 -0
  228. package/actions/solana/signTransaction.ts +53 -0
  229. package/actions/solana/types.ts +87 -0
  230. package/analytics.ts +84 -11
  231. package/client/cdp.ts +11 -4
  232. package/client/evm/evm.ts +162 -33
  233. package/client/evm/evm.types.ts +42 -4
  234. package/client/policies/index.ts +1 -0
  235. package/client/policies/policies.ts +246 -0
  236. package/client/policies/policies.types.ts +109 -0
  237. package/client/solana/solana.ts +107 -38
  238. package/client/solana/solana.types.ts +25 -15
  239. package/index.ts +8 -1
  240. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +360 -0
  241. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +102 -0
  242. package/openapi-client/generated/evm-accounts/evm-accounts.ts +43 -0
  243. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -1
  244. package/openapi-client/generated/index.msw.ts +3 -2
  245. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +404 -0
  246. package/openapi-client/generated/policy-engine/policy-engine.ts +95 -0
  247. package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +75 -0
  248. package/openapi-client/generated/solana-accounts/solana-accounts.ts +23 -0
  249. package/openapi-client/index.ts +7 -0
  250. package/package.json +3 -2
  251. package/policies/schema.ts +266 -0
  252. package/policies/types.ts +19 -0
  253. package/types/misc.ts +41 -0
  254. package/version.ts +1 -1
  255. package/_types/accounts/types.d.ts.map +0 -1
  256. /package/_cjs/accounts/{types.js → evm/types.js} +0 -0
  257. /package/_esm/accounts/{types.js → evm/types.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../policies/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,sBAAsB;IACjC;;;OAGG;;IAKH;;;OAGG;;QA1GH;;;WAGG;;QAEH;;;WAGG;;QAEH;;;WAGG;;YA/HH,gFAAgF;;YAEhF;;;eAGG;;YAEH,8FAA8F;;;;;;;;;;;YAS9F,+EAA+E;;YAE/E;;;;eAIG;;YAEH;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6GH;;;WAGG;;QAEH;;;WAGG;;QAEH;;;WAGG;;YAjHH,kFAAkF;;YAElF;;;eAGG;;YAEH;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8KH,CAAC;AACH;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { PolicyScope, Rule } from "./schema.js";
2
+ /**
3
+ * A single Policy that can be used to govern the behavior of projects and accounts.
4
+ */
5
+ export type Policy = {
6
+ /** The unique identifier for the policy. */
7
+ id: string;
8
+ /** An optional human-readable description of the policy. */
9
+ description?: string;
10
+ /** The scope of the policy. Only one project-level policy can exist at any time. */
11
+ scope: PolicyScope;
12
+ /** A list of rules that comprise the policy. */
13
+ rules: Rule[];
14
+ /** The ISO 8601 timestamp at which the Policy was created. */
15
+ createdAt: string;
16
+ /** The ISO 8601 timestamp at which the Policy was last updated. */
17
+ updatedAt: string;
18
+ };
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../policies/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oFAAoF;IACpF,KAAK,EAAE,WAAW,CAAC;IACnB,gDAAgD;IAChD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -38,4 +38,43 @@ export type TransactionRequestEIP1559 = {
38
38
  /** (Ignored) The transaction type is always `eip1559`. */
39
39
  type?: "eip1559" | undefined;
40
40
  };
41
+ /**
42
+ * The domain of the EIP-712 typed data.
43
+ */
44
+ export interface EIP712Domain {
45
+ /** The name of the DApp or protocol. */
46
+ name?: string;
47
+ /** The version of the DApp or protocol. */
48
+ version?: string;
49
+ /** The chain ID of the EVM network. */
50
+ chainId?: number;
51
+ /** The 0x-prefixed EVM address of the verifying smart contract. */
52
+ verifyingContract?: string;
53
+ /** The optional 32-byte 0x-prefixed hex salt for domain separation. */
54
+ salt?: string;
55
+ }
56
+ /**
57
+ * A mapping of struct names to an array of type objects (name + type).
58
+ * Each key corresponds to a type name (e.g., "`EIP712Domain`", "`PermitTransferFrom`").
59
+ */
60
+ export interface EIP712Types {
61
+ [key: string]: unknown;
62
+ }
63
+ /**
64
+ * The message to sign. The structure of this message must match the `primaryType` struct in the `types` object.
65
+ */
66
+ export type EIP712MessageMessage = {
67
+ [key: string]: unknown;
68
+ };
69
+ /**
70
+ * The message to sign using EIP-712.
71
+ */
72
+ export interface EIP712Message {
73
+ domain: EIP712Domain;
74
+ types: EIP712Types;
75
+ /** The primary type of the message. This is the name of the struct in the `types` object that is the root of the message. */
76
+ primaryType: string;
77
+ /** The message to sign. The structure of this message must match the `primaryType` struct in the `types` object. */
78
+ message: EIP712MessageMessage;
79
+ }
41
80
  //# sourceMappingURL=misc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"misc.d.ts","sourceRoot":"","sources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AW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC;IACnB,6HAA6H;IAC7H,WAAW,EAAE,MAAM,CAAC;IACpB,oHAAoH;IACpH,OAAO,EAAE,oBAAoB,CAAC;CAC/B"}
@@ -1,2 +1,2 @@
1
- export declare const version = "1.6.0";
1
+ export declare const version = "1.8.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -14,11 +14,11 @@ import { sendTransaction } from "../../actions/evm/sendTransaction.js";
14
14
  import { accountTransferStrategy } from "../../actions/evm/transfer/accountTransferStrategy.js";
15
15
  import { transfer } from "../../actions/evm/transfer/transfer.js";
16
16
 
17
+ import type { EvmServerAccount } from "./types.js";
17
18
  import type { SendTransactionOptions } from "../../actions/evm/sendTransaction.js";
18
19
  import type { TransferResult } from "../../actions/evm/transfer/types.js";
19
20
  import type { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
20
- import type { Address, Hash } from "../../types/misc.js";
21
- import type { EvmServerAccount } from "../types.js";
21
+ import type { Address, EIP712Message, Hash } from "../../types/misc.js";
22
22
 
23
23
  /**
24
24
  * Options for converting a pre-existing EvmAccount to a EvmServerAccount.
@@ -64,9 +64,11 @@ export function toEvmServerAccount(
64
64
  return result.signedTransaction as Hex;
65
65
  },
66
66
 
67
- async signTypedData() {
68
- throw new Error("Not implemented");
67
+ async signTypedData(message: EIP712Message) {
68
+ const result = await apiClient.signEvmTypedData(options.account.address, message);
69
+ return result.signature as Hex;
69
70
  },
71
+
70
72
  async transfer(transferArgs): Promise<TransferResult> {
71
73
  return transfer(apiClient, account, transferArgs, accountTransferStrategy);
72
74
  },
@@ -94,6 +96,7 @@ export function toEvmServerAccount(
94
96
  },
95
97
  name: options.account.name,
96
98
  type: "evm-server",
99
+ policies: options.account.policies,
97
100
  };
98
101
 
99
102
  return account;
@@ -1,3 +1,4 @@
1
+ import { getUserOperation } from "../../actions/evm/getUserOperation.js";
1
2
  import {
2
3
  listTokenBalances,
3
4
  type ListTokenBalancesOptions,
@@ -20,14 +21,15 @@ import {
20
21
  WaitForUserOperationOptions,
21
22
  WaitForUserOperationReturnType,
22
23
  } from "../../actions/evm/waitForUserOperation.js";
24
+ import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
23
25
 
26
+ import type { EvmAccount, EvmSmartAccount } from "./types.js";
24
27
  import type { TransferResult } from "../../actions/evm/transfer/types.js";
25
28
  import type {
26
29
  CdpOpenApiClientType,
27
30
  EvmSmartAccount as EvmSmartAccountModel,
28
31
  } from "../../openapi-client/index.js";
29
32
  import type { Address } from "../../types/misc.js";
30
- import type { EvmAccount, EvmSmartAccount } from "../types.js";
31
33
 
32
34
  /**
33
35
  * Options for converting a pre-existing EvmSmartAccount and owner to a EvmSmartAccount
@@ -85,6 +87,14 @@ export function toEvmSmartAccount(
85
87
  smartAccountAddress: account.address,
86
88
  });
87
89
  },
90
+ async getUserOperation(
91
+ options: Omit<GetUserOperationOptions, "smartAccount">,
92
+ ): Promise<UserOperation> {
93
+ return getUserOperation(apiClient, {
94
+ ...options,
95
+ smartAccount: account,
96
+ });
97
+ },
88
98
  async requestFaucet(
89
99
  options: Omit<RequestFaucetOptions, "address">,
90
100
  ): Promise<RequestFaucetResult> {
@@ -1,9 +1,10 @@
1
- import { SignableMessage, TransactionSerializable, TypedData, TypedDataDefinition } from "viem";
1
+ import { SignableMessage, TransactionSerializable } from "viem";
2
2
 
3
- import { Actions } from "../actions/evm/types.js";
4
- import { Prettify } from "../types/utils.js";
3
+ import { Prettify } from "../../types/utils.js";
5
4
 
6
- import type { Hash, Hex, Address } from "../types/misc.js";
5
+ import type { AccountActions, SmartAccountActions } from "../../actions/evm/types.js";
6
+ import type { EIP712Message } from "../../openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js";
7
+ import type { Address, Hash, Hex } from "../../types/misc.js";
7
8
 
8
9
  /**
9
10
  * Base type for any Ethereum account with signing capabilities.
@@ -19,12 +20,9 @@ export type EvmAccount = {
19
20
  /** Signs a transaction and returns the signed transaction as a hex string. */
20
21
  signTransaction: (transaction: TransactionSerializable) => Promise<Hex>;
21
22
  /** Signs a typed data and returns the signature as a hex string. */
22
- signTypedData: <
23
- const typedData extends TypedData | Record<string, unknown>,
24
- primaryType extends keyof typedData | "EIP712Domain" = keyof typedData,
25
- >(
26
- parameters: TypedDataDefinition<typedData, primaryType>,
27
- ) => Promise<Hex>;
23
+ signTypedData: (message: EIP712Message) => Promise<Hex>;
24
+ /** A list of Policy ID's that apply to the account. */
25
+ policies?: string[];
28
26
  };
29
27
 
30
28
  /**
@@ -32,7 +30,7 @@ export type EvmAccount = {
32
30
  */
33
31
  export type EvmServerAccount = Prettify<
34
32
  EvmAccount &
35
- Omit<Actions, "sendUserOperation" | "waitForUserOperation"> & {
33
+ AccountActions & {
36
34
  /** Optional name for the server account. */
37
35
  name?: string;
38
36
  /** Indicates this is a server-managed account. */
@@ -53,5 +51,5 @@ export type EvmSmartAccount = Prettify<
53
51
  owners: EvmAccount[];
54
52
  /** Identifier for the smart account type. */
55
53
  type: "evm-smart";
56
- } & Omit<Actions, "sendTransaction">
54
+ } & SmartAccountActions
57
55
  >;
@@ -0,0 +1,60 @@
1
+ import { Account, SolanaAccount } from "./types.js";
2
+ import { requestFaucet } from "../../actions/solana/requestFaucet.js";
3
+ import { signMessage } from "../../actions/solana/signMessage.js";
4
+ import { signTransaction } from "../../actions/solana/signTransaction.js";
5
+ import {
6
+ RequestFaucetOptions,
7
+ SignatureResult,
8
+ SignMessageOptions,
9
+ SignTransactionOptions,
10
+ } from "../../client/solana/solana.types.js";
11
+ import { CdpOpenApiClientType } from "../../openapi-client/index.js";
12
+ /**
13
+ * Options for converting a pre-existing EvmAccount to a EvmServerAccount.
14
+ */
15
+ export type ToSolanaAccountOptions = {
16
+ /** The Solana account that was previously created. */
17
+ account: Account;
18
+ };
19
+
20
+ /**
21
+ * Creates a Solana account instance with actions from an existing Solana account.
22
+ * Use this to interact with previously deployed Solana accounts, rather than creating new ones.
23
+ *
24
+ * @param {CdpOpenApiClientType} apiClient - The API client.
25
+ * @param {ToSolanaAccountOptions} options - Configuration options.
26
+ * @param {Account} options.account - The Solana account that was previously created.
27
+ * @returns {SolanaAccount} A configured SolanaAccount instance ready for signing.
28
+ */
29
+ export function toSolanaAccount(
30
+ apiClient: CdpOpenApiClientType,
31
+ options: ToSolanaAccountOptions,
32
+ ): SolanaAccount {
33
+ const account: SolanaAccount = {
34
+ address: options.account.address,
35
+ name: options.account.name,
36
+ async requestFaucet(options: Omit<RequestFaucetOptions, "address">): Promise<SignatureResult> {
37
+ return requestFaucet(apiClient, {
38
+ ...options,
39
+ address: account.address,
40
+ });
41
+ },
42
+ async signMessage(options: Omit<SignMessageOptions, "address">): Promise<SignatureResult> {
43
+ return signMessage(apiClient, {
44
+ ...options,
45
+ address: account.address,
46
+ });
47
+ },
48
+ async signTransaction(
49
+ options: Omit<SignTransactionOptions, "address">,
50
+ ): Promise<SignatureResult> {
51
+ return signTransaction(apiClient, {
52
+ ...options,
53
+ address: account.address,
54
+ });
55
+ },
56
+ policies: options.account.policies,
57
+ };
58
+
59
+ return account;
60
+ }
@@ -0,0 +1,13 @@
1
+ import { AccountActions } from "../../actions/solana/types.js";
2
+ import { SolanaAccount as OpenAPISolanaAccount } from "../../openapi-client/index.js";
3
+ import { Prettify } from "../../types/utils.js";
4
+
5
+ /**
6
+ * A base Solana account.
7
+ */
8
+ export type Account = OpenAPISolanaAccount;
9
+
10
+ /**
11
+ * A Solana account with actions.
12
+ */
13
+ export type SolanaAccount = Prettify<OpenAPISolanaAccount & AccountActions>;
@@ -0,0 +1,40 @@
1
+ import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
2
+ import { CdpOpenApiClientType } from "../../openapi-client/index.js";
3
+ import { Address, Hex } from "../../types/misc.js";
4
+
5
+ /**
6
+ * Gets a user operation for a smart account by user operation hash.
7
+ *
8
+ * @param {CdpOpenApiClientType} client - The client to use to get the user operation.
9
+ * @param {GetUserOperationOptions} options - Parameters for getting the user operation.
10
+ * @param {SmartAccount} options.smartAccount - The smart account signing the user operation.
11
+ * @param {string} options.userOpHash - The user operation hash.
12
+ *
13
+ * @returns A promise that resolves to the user operation.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const userOp = await getUserOperation(client, {
18
+ * smartAccount,
19
+ * userOpHash: "0x1234567890123456789012345678901234567890123456789012345678901234",
20
+ * });
21
+ * ```
22
+ */
23
+ export async function getUserOperation(
24
+ client: CdpOpenApiClientType,
25
+ options: GetUserOperationOptions,
26
+ ): Promise<UserOperation> {
27
+ const userOp = await client.getUserOperation(options.smartAccount.address, options.userOpHash);
28
+
29
+ return {
30
+ calls: userOp.calls.map(call => ({
31
+ to: call.to as Address,
32
+ value: BigInt(call.value),
33
+ data: call.data as Hex,
34
+ })),
35
+ network: userOp.network,
36
+ status: userOp.status,
37
+ transactionHash: userOp.transactionHash as Hex | undefined,
38
+ userOpHash: userOp.userOpHash as Hex,
39
+ };
40
+ }
@@ -6,7 +6,7 @@ import {
6
6
  CdpOpenApiClientType,
7
7
  } from "../../openapi-client/index.js";
8
8
 
9
- import type { EvmSmartAccount } from "../../accounts/types.js";
9
+ import type { EvmSmartAccount } from "../../accounts/evm/types.js";
10
10
  import type { Calls } from "../../types/calls.js";
11
11
  import type { Address, Hex } from "../../types/misc.js";
12
12
 
@@ -8,23 +8,23 @@ import {
8
8
 
9
9
  import { TransferExecutionStrategy } from "./types.js";
10
10
  import { getErc20Address } from "./utils.js";
11
- import { EvmAccount } from "../../../accounts/types.js";
11
+ import { EvmAccount } from "../../../accounts/evm/types.js";
12
12
  import { serializeEIP1559Transaction } from "../../../utils/serializeTransaction.js";
13
13
 
14
14
  export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
15
- executeTransfer: async ({ apiClient, from, transferArgs, to, value }) => {
15
+ executeTransfer: async ({ apiClient, from, to, value, token, network }) => {
16
16
  const transactionHash = await (async () => {
17
- if (transferArgs.token === "eth") {
17
+ if (token === "eth") {
18
18
  const result = await apiClient.sendEvmTransaction(from.address, {
19
19
  transaction: serializeEIP1559Transaction({
20
20
  value,
21
21
  to,
22
22
  }),
23
- network: transferArgs.network,
23
+ network,
24
24
  });
25
25
  return result.transactionHash as Hex;
26
26
  } else {
27
- const erc20Address = getErc20Address(transferArgs.token, transferArgs.network);
27
+ const erc20Address = getErc20Address(token, network);
28
28
 
29
29
  await apiClient.sendEvmTransaction(from.address, {
30
30
  transaction: serializeEIP1559Transaction({
@@ -35,7 +35,7 @@ export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
35
35
  args: [to, value],
36
36
  }),
37
37
  }),
38
- network: transferArgs.network,
38
+ network,
39
39
  });
40
40
 
41
41
  const result = await apiClient.sendEvmTransaction(from.address, {
@@ -47,7 +47,7 @@ export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
47
47
  args: [to, value],
48
48
  }),
49
49
  }),
50
- network: transferArgs.network,
50
+ network,
51
51
  });
52
52
 
53
53
  return result.transactionHash as Hex;
@@ -57,11 +57,15 @@ export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
57
57
  return transactionHash;
58
58
  },
59
59
 
60
- waitForResult: async ({ publicClient, hash }) => {
60
+ waitForResult: async ({ publicClient, hash, waitOptions }) => {
61
61
  let receipt: TransactionReceipt;
62
62
  try {
63
63
  receipt = await publicClient.waitForTransactionReceipt({
64
64
  hash,
65
+ pollingInterval: waitOptions?.intervalSeconds
66
+ ? waitOptions.intervalSeconds * 1000
67
+ : undefined,
68
+ timeout: waitOptions?.timeoutSeconds ? waitOptions.timeoutSeconds * 1000 : undefined,
65
69
  });
66
70
  } catch (error) {
67
71
  if (error instanceof WaitForTransactionReceiptTimeoutError) {
@@ -2,17 +2,18 @@ import { encodeFunctionData, erc20Abi } from "viem";
2
2
 
3
3
  import { TransferExecutionStrategy } from "./types.js";
4
4
  import { getErc20Address } from "./utils.js";
5
- import { EvmSmartAccount } from "../../../accounts/types.js";
5
+ import { EvmSmartAccount } from "../../../accounts/evm/types.js";
6
6
  import { sendUserOperation } from "../sendUserOperation.js";
7
7
  import { waitForUserOperation } from "../waitForUserOperation.js";
8
8
 
9
9
  export const smartAccountTransferStrategy: TransferExecutionStrategy<EvmSmartAccount> = {
10
- executeTransfer: async ({ apiClient, from, transferArgs, to, value }) => {
10
+ executeTransfer: async ({ apiClient, from, to, value, token, network, paymasterUrl }) => {
11
11
  const userOpHash = await (async () => {
12
- if (transferArgs.token === "eth") {
12
+ if (token === "eth") {
13
13
  const result = await sendUserOperation(apiClient, {
14
14
  smartAccount: from,
15
- network: transferArgs.network,
15
+ paymasterUrl,
16
+ network,
16
17
  calls: [
17
18
  {
18
19
  to,
@@ -23,11 +24,12 @@ export const smartAccountTransferStrategy: TransferExecutionStrategy<EvmSmartAcc
23
24
  });
24
25
  return result.userOpHash;
25
26
  } else {
26
- const erc20Address = getErc20Address(transferArgs.token, transferArgs.network);
27
+ const erc20Address = getErc20Address(token, network);
27
28
 
28
29
  const result = await sendUserOperation(apiClient, {
29
30
  smartAccount: from,
30
- network: transferArgs.network,
31
+ paymasterUrl,
32
+ network,
31
33
  calls: [
32
34
  {
33
35
  to: erc20Address,
@@ -55,10 +57,11 @@ export const smartAccountTransferStrategy: TransferExecutionStrategy<EvmSmartAcc
55
57
  return userOpHash;
56
58
  },
57
59
 
58
- waitForResult: async ({ apiClient, publicClient, from, hash }) => {
60
+ waitForResult: async ({ apiClient, publicClient, from, hash, waitOptions }) => {
59
61
  const result = await waitForUserOperation(apiClient, {
60
62
  smartAccountAddress: from.address,
61
63
  userOpHash: hash,
64
+ waitOptions,
62
65
  });
63
66
 
64
67
  if (result.status === "complete") {
@@ -1,10 +1,16 @@
1
1
  import { createPublicClient, http, erc20Abi, parseUnits, Address, Chain, Transport } from "viem";
2
2
 
3
- import { TransferResult, TransferOptions, TransferExecutionStrategy } from "./types.js";
4
3
  import { mapNetworkToChain } from "./utils.js";
5
- import { EvmAccount, EvmSmartAccount } from "../../../accounts/types.js";
4
+ import { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
6
5
  import { CdpOpenApiClientType } from "../../../openapi-client/index.js";
7
6
 
7
+ import type {
8
+ TransferResult,
9
+ TransferExecutionStrategy,
10
+ SmartAccountTransferOptions,
11
+ AccountTransferOptions,
12
+ } from "./types.js";
13
+
8
14
  /**
9
15
  * Transfer an amount of a token from an account to another account.
10
16
  *
@@ -17,7 +23,7 @@ import { CdpOpenApiClientType } from "../../../openapi-client/index.js";
17
23
  export async function transfer<T extends EvmAccount | EvmSmartAccount>(
18
24
  apiClient: CdpOpenApiClientType,
19
25
  from: T,
20
- transferArgs: TransferOptions,
26
+ transferArgs: T extends EvmSmartAccount ? SmartAccountTransferOptions : AccountTransferOptions,
21
27
  transferStrategy: TransferExecutionStrategy<T>,
22
28
  ): Promise<TransferResult> {
23
29
  const publicClient = createPublicClient<Transport, Chain>({
@@ -52,19 +58,24 @@ export async function transfer<T extends EvmAccount | EvmSmartAccount>(
52
58
  return parseUnits(transferArgs.amount, decimals);
53
59
  })();
54
60
 
55
- const hash = await transferStrategy.executeTransfer({
61
+ const transfer = {
56
62
  apiClient,
57
63
  from,
58
- transferArgs,
59
64
  to,
60
65
  value,
61
- });
66
+ token: transferArgs.token,
67
+ network: transferArgs.network,
68
+ paymasterUrl: "paymasterUrl" in transferArgs ? transferArgs.paymasterUrl : undefined,
69
+ };
70
+
71
+ const hash = await transferStrategy.executeTransfer(transfer);
62
72
 
63
73
  const result = await transferStrategy.waitForResult({
64
74
  apiClient,
65
75
  publicClient,
66
76
  from,
67
77
  hash,
78
+ waitOptions: transferArgs.waitOptions,
68
79
  });
69
80
 
70
81
  return result;
@@ -1,12 +1,22 @@
1
- import { Hex, TransactionReceipt, Address, PublicClient, Chain, Transport } from "viem";
1
+ import {
2
+ Hex,
3
+ TransactionReceipt,
4
+ Address,
5
+ PublicClient,
6
+ Chain,
7
+ Transport,
8
+ WaitForTransactionReceiptParameters,
9
+ } from "viem";
2
10
 
3
11
  import {
4
12
  CdpOpenApiClientType,
5
- EvmAccount,
6
13
  EvmUserOperationNetwork,
7
14
  SendEvmTransactionBodyNetwork,
8
15
  } from "../../../openapi-client/index.js";
9
16
 
17
+ import type { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
18
+ import type { WaitForUserOperationOptions } from "../waitForUserOperation.js";
19
+
10
20
  /**
11
21
  * The network to transfer the token on.
12
22
  */
@@ -29,6 +39,33 @@ export type TransferOptions = {
29
39
  network: Network;
30
40
  };
31
41
 
42
+ /**
43
+ * The options for the transfer using an account.
44
+ */
45
+ export type AccountTransferOptions = TransferOptions & {
46
+ /** The options for waiting for the result of the transfer. */
47
+ waitOptions?: {
48
+ /**
49
+ * Polling frequency (in seconds). Defaults to 4 seconds.
50
+ */
51
+ intervalSeconds?: WaitForTransactionReceiptParameters["pollingInterval"];
52
+ /**
53
+ * Optional timeout (in seconds) to wait before stopping polling. Defaults to 180 seconds.
54
+ */
55
+ timeoutSeconds?: WaitForTransactionReceiptParameters["timeout"];
56
+ };
57
+ };
58
+
59
+ /**
60
+ * The options for the transfer using a smart account.
61
+ */
62
+ export type SmartAccountTransferOptions = TransferOptions & {
63
+ /** The paymaster URL to use for the transfer. */
64
+ paymasterUrl?: string;
65
+ /** The options for waiting for the result of the transfer. */
66
+ waitOptions?: WaitForUserOperationOptions["waitOptions"];
67
+ };
68
+
32
69
  /**
33
70
  * The result of the transfer.
34
71
  */
@@ -42,25 +79,29 @@ export type TransferResult = {
42
79
  /**
43
80
  * A strategy for executing a transfer.
44
81
  */
45
- export interface TransferExecutionStrategy<T> {
82
+ export interface TransferExecutionStrategy<T extends EvmAccount | EvmSmartAccount> {
46
83
  /**
47
84
  * Executes the transfer.
48
85
  *
49
86
  * @param args - The arguments for the transfer.
50
87
  * @param args.apiClient - The API client to use for the transfer.
51
88
  * @param args.from - The account to transfer the token from.
52
- * @param args.transferArgs - The arguments for the transfer.
53
89
  * @param args.to - The account to transfer the token to.
54
90
  * @param args.value - The value of the transfer.
91
+ * @param args.token - The token to transfer.
92
+ * @param args.network - The network to transfer the token on.
55
93
  * @returns The transaction hash of the transfer.
56
94
  */
57
- executeTransfer(args: {
58
- apiClient: CdpOpenApiClientType;
59
- from: T;
60
- transferArgs: TransferOptions;
61
- to: Address;
62
- value: bigint;
63
- }): Promise<Hex>;
95
+ executeTransfer(
96
+ args: {
97
+ apiClient: CdpOpenApiClientType;
98
+ from: T;
99
+ to: Address;
100
+ value: bigint;
101
+ token: TransferOptions["token"];
102
+ network: TransferOptions["network"];
103
+ } & (T extends EvmSmartAccount ? { paymasterUrl?: string } : object),
104
+ ): Promise<Hex>;
64
105
 
65
106
  /**
66
107
  * Waits for the result of the transfer.
@@ -70,6 +111,7 @@ export interface TransferExecutionStrategy<T> {
70
111
  * @param args.publicClient - The public client to use for the transfer.
71
112
  * @param args.from - The account to transfer the token from.
72
113
  * @param args.hash - The transaction hash of the transfer.
114
+ * @param args.waitOptions - The options for waiting for the result of the transfer.
73
115
  * @returns The result of the transfer.
74
116
  */
75
117
  waitForResult(args: {
@@ -77,5 +119,6 @@ export interface TransferExecutionStrategy<T> {
77
119
  publicClient: PublicClient<Transport, Chain>;
78
120
  from: T;
79
121
  hash: Hex;
122
+ waitOptions?: WaitForUserOperationOptions["waitOptions"];
80
123
  }): Promise<TransferResult>;
81
124
  }