@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,109 @@
1
+ import { OpenApiPoliciesMethods } from "../../openapi-client/index.js";
2
+ import { CreatePolicyBody, PolicyScope, UpdatePolicyBody } from "../../policies/schema.js";
3
+ import { Policy } from "../../policies/types.js";
4
+
5
+ /**
6
+ * The PoliciesClient type, where all OpenApiPoliciesMethods methods are wrapped.
7
+ */
8
+ export type PoliciesClientInterface = Omit<
9
+ typeof OpenApiPoliciesMethods,
10
+ | "createPolicy" // mapped to createPolicy
11
+ | "listPolicies" // mapped to listPolicies
12
+ | "getPolicyById" // mapped to getPolicyById
13
+ | "deletePolicy" // mapped to deletePolicy
14
+ | "updatePolicy" // mapped to updatePolicy
15
+ > & {
16
+ listPolicies: (options: ListPoliciesOptions) => Promise<ListPoliciesResult>;
17
+ createPolicy: (options: CreatePolicyOptions) => Promise<Policy>;
18
+ getPolicyById: (options: GetPolicyByIdOptions) => Promise<Policy>;
19
+ deletePolicy: (options: DeletePolicyOptions) => Promise<void>;
20
+ updatePolicy: (options: UpdatePolicyOptions) => Promise<Policy>;
21
+ };
22
+
23
+ export interface ListPoliciesOptions {
24
+ /** The page size to paginate through the accounts. */
25
+ pageSize?: number;
26
+ /** The page token to paginate through the accounts. */
27
+ pageToken?: string;
28
+ /**
29
+ * The scope of the policies to return. If `project`, the response will include exactly one policy, which is the project-level policy. If `account`, the response will include all account-level policies for the developer's CDP Project.
30
+ */
31
+ scope?: PolicyScope;
32
+ }
33
+
34
+ /**
35
+ * The result of listing policies.
36
+ */
37
+ export interface ListPoliciesResult {
38
+ /** The list of policies matching the query parameters. */
39
+ policies: Policy[];
40
+ /**
41
+ * The next page token to paginate through the policies.
42
+ * If undefined, there are no more policies to paginate through.
43
+ */
44
+ nextPageToken?: string;
45
+ }
46
+
47
+ /**
48
+ * Options for creating a Policy.
49
+ */
50
+ export interface CreatePolicyOptions {
51
+ /**
52
+ * The idempotency key to ensure the request is processed exactly once.
53
+ * Used to safely retry requests without accidentally performing the same operation twice.
54
+ */
55
+ idempotencyKey?: string;
56
+ /**
57
+ * The policy definition to create.
58
+ * Contains the scope, description, and rules for the policy.
59
+ */
60
+ policy: CreatePolicyBody;
61
+ }
62
+
63
+ /**
64
+ * Options for retrieving a Policy by ID.
65
+ */
66
+ export interface GetPolicyByIdOptions {
67
+ /**
68
+ * The unique identifier of the policy to retrieve.
69
+ * This is a UUID that's generated when the policy is created.
70
+ */
71
+ id: string;
72
+ }
73
+
74
+ /**
75
+ * Options for deleting a Policy.
76
+ */
77
+ export interface DeletePolicyOptions {
78
+ /**
79
+ * The unique identifier of the policy to delete.
80
+ * This is a UUID that's generated when the policy is created.
81
+ */
82
+ id: string;
83
+ /**
84
+ * The idempotency key to ensure the request is processed exactly once.
85
+ * Used to safely retry requests without accidentally performing the same operation twice.
86
+ */
87
+ idempotencyKey?: string;
88
+ }
89
+
90
+ /**
91
+ * Options for updating a Policy.
92
+ */
93
+ export interface UpdatePolicyOptions {
94
+ /**
95
+ * The unique identifier of the policy to update.
96
+ * This is a UUID that's generated when the policy is created.
97
+ */
98
+ id: string;
99
+ /**
100
+ * The updated policy definition.
101
+ * Contains the description and rules for the policy.
102
+ */
103
+ policy: UpdatePolicyBody;
104
+ /**
105
+ * The idempotency key to ensure the request is processed exactly once.
106
+ * Used to safely retry requests without accidentally performing the same operation twice.
107
+ */
108
+ idempotencyKey?: string;
109
+ }
@@ -1,16 +1,22 @@
1
1
  import {
2
- SolanaClientInterface,
3
- Account,
4
2
  CreateAccountOptions,
5
3
  GetAccountOptions,
4
+ GetOrCreateAccountOptions,
6
5
  ListAccountsOptions,
7
- RequestFaucetOptions,
8
6
  ListAccountsResult,
7
+ RequestFaucetOptions,
9
8
  SignatureResult,
10
9
  SignMessageOptions,
11
10
  SignTransactionOptions,
12
- GetOrCreateAccountOptions,
11
+ SolanaClientInterface,
12
+ UpdateSolanaAccountOptions,
13
13
  } from "./solana.types.js";
14
+ import { toSolanaAccount } from "../../accounts/solana/toSolanaAccount.js";
15
+ import { SolanaAccount } from "../../accounts/solana/types.js";
16
+ import { requestFaucet } from "../../actions/solana/requestFaucet.js";
17
+ import { signMessage } from "../../actions/solana/signMessage.js";
18
+ import { signTransaction } from "../../actions/solana/signTransaction.js";
19
+ import { Analytics } from "../../analytics.js";
14
20
  import { APIError } from "../../openapi-client/errors.js";
15
21
  import { CdpOpenApiClient } from "../../openapi-client/index.js";
16
22
 
@@ -48,8 +54,19 @@ export class SolanaClient implements SolanaClientInterface {
48
54
  * await cdp.solana.createAccount({ idempotencyKey });
49
55
  * ```
50
56
  */
51
- async createAccount(options: CreateAccountOptions = {}): Promise<Account> {
52
- return CdpOpenApiClient.createSolanaAccount(options, options.idempotencyKey);
57
+ async createAccount(options: CreateAccountOptions = {}): Promise<SolanaAccount> {
58
+ const openApiAccount = await CdpOpenApiClient.createSolanaAccount(
59
+ options,
60
+ options.idempotencyKey,
61
+ );
62
+
63
+ const account = toSolanaAccount(CdpOpenApiClient, {
64
+ account: openApiAccount,
65
+ });
66
+
67
+ Analytics.wrapObjectMethodsWithErrorTracking(account);
68
+
69
+ return account;
53
70
  }
54
71
 
55
72
  /**
@@ -77,16 +94,26 @@ export class SolanaClient implements SolanaClientInterface {
77
94
  * });
78
95
  * ```
79
96
  */
80
- async getAccount(options: GetAccountOptions): Promise<Account> {
81
- if (options.address) {
82
- return CdpOpenApiClient.getSolanaAccount(options.address);
83
- }
97
+ async getAccount(options: GetAccountOptions): Promise<SolanaAccount> {
98
+ const openApiAccount = await (() => {
99
+ if (options.address) {
100
+ return CdpOpenApiClient.getSolanaAccount(options.address);
101
+ }
84
102
 
85
- if (options.name) {
86
- return CdpOpenApiClient.getSolanaAccountByName(options.name);
87
- }
103
+ if (options.name) {
104
+ return CdpOpenApiClient.getSolanaAccountByName(options.name);
105
+ }
106
+
107
+ throw new Error("Either address or name must be provided");
108
+ })();
109
+
110
+ const account = toSolanaAccount(CdpOpenApiClient, {
111
+ account: openApiAccount,
112
+ });
88
113
 
89
- throw new Error("Either address or name must be provided");
114
+ Analytics.wrapObjectMethodsWithErrorTracking(account);
115
+
116
+ return account;
90
117
  }
91
118
 
92
119
  /**
@@ -104,7 +131,7 @@ export class SolanaClient implements SolanaClientInterface {
104
131
  * });
105
132
  * ```
106
133
  */
107
- async getOrCreateAccount(options: GetOrCreateAccountOptions): Promise<Account> {
134
+ async getOrCreateAccount(options: GetOrCreateAccountOptions): Promise<SolanaAccount> {
108
135
  try {
109
136
  const account = await this.getAccount(options);
110
137
  return account;
@@ -165,7 +192,15 @@ export class SolanaClient implements SolanaClientInterface {
165
192
  });
166
193
 
167
194
  return {
168
- accounts: solAccounts.accounts,
195
+ accounts: solAccounts.accounts.map(account => {
196
+ const solanaAccount = toSolanaAccount(CdpOpenApiClient, {
197
+ account,
198
+ });
199
+
200
+ Analytics.wrapObjectMethodsWithErrorTracking(solanaAccount);
201
+
202
+ return solanaAccount;
203
+ }),
169
204
  nextPageToken: solAccounts.nextPageToken,
170
205
  };
171
206
  }
@@ -189,14 +224,7 @@ export class SolanaClient implements SolanaClientInterface {
189
224
  * ```
190
225
  */
191
226
  async requestFaucet(options: RequestFaucetOptions): Promise<SignatureResult> {
192
- const signature = await CdpOpenApiClient.requestSolanaFaucet(
193
- { address: options.address, token: options.token },
194
- options.idempotencyKey,
195
- );
196
-
197
- return {
198
- signature: signature.transactionSignature,
199
- };
227
+ return requestFaucet(CdpOpenApiClient, options);
200
228
  }
201
229
 
202
230
  /**
@@ -222,13 +250,7 @@ export class SolanaClient implements SolanaClientInterface {
222
250
  * ```
223
251
  */
224
252
  async signMessage(options: SignMessageOptions): Promise<SignatureResult> {
225
- return CdpOpenApiClient.signSolanaMessage(
226
- options.address,
227
- {
228
- message: options.message,
229
- },
230
- options.idempotencyKey,
231
- );
253
+ return signMessage(CdpOpenApiClient, options);
232
254
  }
233
255
 
234
256
  /**
@@ -265,16 +287,63 @@ export class SolanaClient implements SolanaClientInterface {
265
287
  * ```
266
288
  */
267
289
  async signTransaction(options: SignTransactionOptions): Promise<SignatureResult> {
268
- const signature = await CdpOpenApiClient.signSolanaTransaction(
290
+ return signTransaction(CdpOpenApiClient, options);
291
+ }
292
+
293
+ /**
294
+ * Updates a CDP Solana account.
295
+ *
296
+ * @param {UpdateSolanaAccountOptions} [options] - Optional parameters for creating the account.
297
+ * @param {string} options.address - The address of the account to update
298
+ * @param {UpdateSolanaAccountBody} options.update - An object containing account fields to update.
299
+ * @param {string} [options.update.name] - The new name for the account.
300
+ * @param {string} [options.update.accountPolicy] - The ID of a Policy to apply to the account.
301
+ * @param {string} [options.idempotencyKey] - An idempotency key.
302
+ *
303
+ * @returns A promise that resolves to the updated account.
304
+ *
305
+ * @example **With a name**
306
+ * ```ts
307
+ * const account = await cdp.sol.updateAccount({ address: "...", update: { name: "New Name" } });
308
+ * ```
309
+ *
310
+ * @example **With an account policy**
311
+ * ```ts
312
+ * const account = await cdp.sol.updateAccount({ address: "...", update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" } });
313
+ * ```
314
+ *
315
+ * @example **With an idempotency key**
316
+ * ```ts
317
+ * const idempotencyKey = uuidv4();
318
+ *
319
+ * // First call
320
+ * await cdp.sol.updateAccount({
321
+ * address: "0x...",
322
+ * update: { accountPolicy: "73bcaeeb-d7af-4615-b064-42b5fe83a31e" },
323
+ * idempotencyKey,
324
+ * });
325
+ *
326
+ * // Second call with the same idempotency key will not update
327
+ * await cdp.sol.updateAccount({
328
+ * address: '0x...',
329
+ * update: { name: "" },
330
+ * idempotencyKey,
331
+ * });
332
+ * ```
333
+ */
334
+ async updateAccount(options: UpdateSolanaAccountOptions): Promise<SolanaAccount> {
335
+ const openApiAccount = await CdpOpenApiClient.updateSolanaAccount(
269
336
  options.address,
270
- {
271
- transaction: options.transaction,
272
- },
337
+ options.update,
273
338
  options.idempotencyKey,
274
339
  );
275
340
 
276
- return {
277
- signature: signature.signedTransaction,
278
- };
341
+ const account = toSolanaAccount(CdpOpenApiClient, {
342
+ account: openApiAccount,
343
+ });
344
+
345
+ Analytics.wrapObjectMethodsWithErrorTracking(account);
346
+
347
+ return account;
279
348
  }
280
349
  }
@@ -1,7 +1,6 @@
1
- import {
2
- OpenApiSolanaMethods,
3
- SolanaAccount as OpenAPISolanaAccount,
4
- } from "../../openapi-client/index.js";
1
+ import { Account, SolanaAccount } from "../../accounts/solana/types.js";
2
+ import { OpenApiSolanaMethods, UpdateSolanaAccountBody } from "../../openapi-client/index.js";
3
+
5
4
  /**
6
5
  * The SolanaClient type, where all OpenApiSolanaMethods methods are wrapped.
7
6
  */
@@ -10,23 +9,30 @@ export type SolanaClientInterface = Omit<
10
9
  | "createSolanaAccount" // mapped to createAccount
11
10
  | "getSolanaAccount" // mapped to getAccount
12
11
  | "getSolanaAccountByName" // mapped to getAccount
12
+ | "updateSolanaAccount" // mapped to updateAccount
13
13
  | "listSolanaAccounts" // mapped to listAccounts
14
14
  | "requestSolanaFaucet" // mapped to requestFaucet
15
15
  | "signSolanaMessage" // mapped to signMessage
16
16
  | "signSolanaTransaction" // mapped to signTransaction
17
+ | "updateSolanaAccount" // mapped to updateAccount
17
18
  > & {
18
19
  createAccount: (options: CreateAccountOptions) => Promise<Account>;
19
20
  getAccount: (options: GetAccountOptions) => Promise<Account>;
20
21
  getOrCreateAccount: (options: GetOrCreateAccountOptions) => Promise<Account>;
22
+ updateAccount: (options: UpdateSolanaAccountOptions) => Promise<Account>;
21
23
  listAccounts: (options: ListAccountsOptions) => Promise<ListAccountsResult>;
22
24
  requestFaucet: (options: RequestFaucetOptions) => Promise<SignatureResult>;
23
25
  signMessage: (options: SignMessageOptions) => Promise<SignatureResult>;
24
26
  signTransaction: (options: SignTransactionOptions) => Promise<SignatureResult>;
25
27
  };
28
+
26
29
  /**
27
- * A Solana account.
30
+ * A Solana signature result.
28
31
  */
29
- export type Account = OpenAPISolanaAccount;
32
+ export interface SignatureResult {
33
+ /** The signature. */
34
+ signature: string;
35
+ }
30
36
 
31
37
  /**
32
38
  * Options for creating a Solana account.
@@ -56,6 +62,18 @@ export interface GetOrCreateAccountOptions {
56
62
  name: string;
57
63
  }
58
64
 
65
+ /**
66
+ * Options for creating a SOL server account.
67
+ */
68
+ export interface UpdateSolanaAccountOptions {
69
+ /** The address of the account. */
70
+ address: string;
71
+ /** The updates to apply to the account */
72
+ update: UpdateSolanaAccountBody;
73
+ /** The idempotency key. */
74
+ idempotencyKey?: string;
75
+ }
76
+
59
77
  /**
60
78
  * Options for listing Solana accounts.
61
79
  */
@@ -71,7 +89,7 @@ export interface ListAccountsOptions {
71
89
  */
72
90
  export interface ListAccountsResult {
73
91
  /** The accounts. */
74
- accounts: Account[];
92
+ accounts: SolanaAccount[];
75
93
  /**
76
94
  * The token for the next page of accounts, if any.
77
95
  */
@@ -113,11 +131,3 @@ export interface SignTransactionOptions {
113
131
  /** The idempotency key. */
114
132
  idempotencyKey?: string;
115
133
  }
116
-
117
- /**
118
- * A Solana signature result.
119
- */
120
- export interface SignatureResult {
121
- /** The signature. */
122
- signature: string;
123
- }
package/index.ts CHANGED
@@ -1,2 +1,9 @@
1
1
  export { CdpClient } from "./client/cdp.js";
2
- export type { EvmServerAccount, EvmSmartAccount } from "./accounts/types.js";
2
+ export type { EvmServerAccount, EvmSmartAccount } from "./accounts/evm/types.js";
3
+ export type { Policy } from "./policies/types.js";
4
+ export {
5
+ CreatePolicyBodySchema,
6
+ UpdatePolicyBodySchema,
7
+ type CreatePolicyBody,
8
+ type UpdatePolicyBody,
9
+ } from "./policies/schema.js";