@coinbase/cdp-sdk 1.12.0 → 1.14.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 (122) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +20 -2
  3. package/_cjs/accounts/evm/toEvmServerAccount.js +6 -0
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  5. package/_cjs/actions/evm/listTokenBalances.js +1 -1
  6. package/_cjs/actions/evm/listTokenBalances.js.map +1 -1
  7. package/_cjs/analytics.js +1 -1
  8. package/_cjs/analytics.js.map +1 -1
  9. package/_cjs/client/evm/evm.js +59 -2
  10. package/_cjs/client/evm/evm.js.map +1 -1
  11. package/_cjs/openapi-client/cdpApiClient.js +15 -2
  12. package/_cjs/openapi-client/cdpApiClient.js.map +1 -1
  13. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +24 -1
  14. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  15. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +27 -1
  16. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  17. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +32 -1
  18. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  19. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +9 -1
  20. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  21. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +23 -1
  22. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  23. package/_cjs/openapi-client/generated/faucets/faucets.js +1 -1
  24. package/_cjs/openapi-client/generated/index.msw.js +5 -5
  25. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  26. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +59 -1
  27. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  28. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js +27 -1
  29. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  30. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +32 -1
  31. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  32. package/_cjs/policies/schema.js +59 -1
  33. package/_cjs/policies/schema.js.map +1 -1
  34. package/_cjs/version.js +1 -1
  35. package/_esm/accounts/evm/toEvmServerAccount.js +7 -1
  36. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  37. package/_esm/actions/evm/listTokenBalances.js +1 -1
  38. package/_esm/actions/evm/listTokenBalances.js.map +1 -1
  39. package/_esm/analytics.js +2 -2
  40. package/_esm/analytics.js.map +1 -1
  41. package/_esm/client/evm/evm.js +59 -2
  42. package/_esm/client/evm/evm.js.map +1 -1
  43. package/_esm/openapi-client/cdpApiClient.js +15 -2
  44. package/_esm/openapi-client/cdpApiClient.js.map +1 -1
  45. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +23 -0
  46. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  47. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +24 -0
  48. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  49. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +27 -0
  50. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  51. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +7 -0
  52. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  53. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +20 -0
  54. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  55. package/_esm/openapi-client/generated/faucets/faucets.js +1 -1
  56. package/_esm/openapi-client/generated/index.msw.js +5 -5
  57. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  58. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +54 -0
  59. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  60. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +24 -0
  61. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  62. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +27 -0
  63. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  64. package/_esm/policies/schema.js +58 -0
  65. package/_esm/policies/schema.js.map +1 -1
  66. package/_esm/version.js +1 -1
  67. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  68. package/_types/actions/evm/listTokenBalances.d.ts +1 -1
  69. package/_types/actions/evm/swap/types.d.ts +40 -1
  70. package/_types/actions/evm/swap/types.d.ts.map +1 -1
  71. package/_types/client/evm/evm.d.ts +25 -2
  72. package/_types/client/evm/evm.d.ts.map +1 -1
  73. package/_types/client/evm/evm.types.d.ts +15 -2
  74. package/_types/client/evm/evm.types.d.ts.map +1 -1
  75. package/_types/client/solana/solana.types.d.ts +1 -1
  76. package/_types/client/solana/solana.types.d.ts.map +1 -1
  77. package/_types/openapi-client/cdpApiClient.d.ts.map +1 -1
  78. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +108 -5
  79. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  80. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -1
  81. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  82. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -1
  83. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
  84. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +6 -0
  85. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  86. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts +2 -0
  87. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
  88. package/_types/openapi-client/generated/faucets/faucets.d.ts +1 -1
  89. package/_types/openapi-client/generated/index.msw.d.ts +5 -5
  90. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  91. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
  92. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
  93. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +13 -1
  94. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
  95. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +5 -1
  96. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
  97. package/_types/openapi-client/index.d.ts +10 -0
  98. package/_types/openapi-client/index.d.ts.map +1 -1
  99. package/_types/policies/schema.d.ts +338 -0
  100. package/_types/policies/schema.d.ts.map +1 -1
  101. package/_types/version.d.ts +1 -1
  102. package/accounts/evm/toEvmServerAccount.ts +8 -3
  103. package/actions/evm/listTokenBalances.ts +2 -2
  104. package/actions/evm/swap/types.ts +44 -1
  105. package/analytics.ts +2 -2
  106. package/client/evm/evm.ts +59 -2
  107. package/client/evm/evm.types.ts +18 -1
  108. package/client/solana/solana.types.ts +2 -0
  109. package/openapi-client/cdpApiClient.ts +17 -2
  110. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +145 -5
  111. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +61 -0
  112. package/openapi-client/generated/evm-accounts/evm-accounts.ts +46 -0
  113. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +38 -0
  114. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +16 -0
  115. package/openapi-client/generated/faucets/faucets.ts +1 -1
  116. package/openapi-client/generated/index.msw.ts +5 -5
  117. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +87 -0
  118. package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +61 -0
  119. package/openapi-client/generated/solana-accounts/solana-accounts.ts +48 -0
  120. package/package.json +1 -1
  121. package/policies/schema.ts +70 -0
  122. package/version.ts +1 -1
@@ -12,6 +12,7 @@ import { HttpResponse, delay, http } from "msw";
12
12
  import type {
13
13
  EthValueCriterion,
14
14
  EvmAddressCriterion,
15
+ EvmMessageCriterion,
15
16
  EvmNetworkCriterion,
16
17
  ListPolicies200,
17
18
  Policy,
@@ -53,6 +54,13 @@ export const getListPoliciesResponseEvmNetworkCriterionMock = (
53
54
  ...overrideResponse,
54
55
  });
55
56
 
57
+ export const getListPoliciesResponseEvmMessageCriterionMock = (
58
+ overrideResponse: Partial<EvmMessageCriterion> = {},
59
+ ): EvmMessageCriterion => ({
60
+ ...{ type: faker.helpers.arrayElement(["evmMessage"] as const), match: faker.string.alpha(20) },
61
+ ...overrideResponse,
62
+ });
63
+
56
64
  export const getListPoliciesResponseSolAddressCriterionMock = (
57
65
  overrideResponse: Partial<SolAddressCriterion> = {},
58
66
  ): SolAddressCriterion => ({
@@ -108,6 +116,18 @@ export const getListPoliciesResponseMock = (): ListPolicies200 => ({
108
116
  ]),
109
117
  ),
110
118
  },
119
+ {
120
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
121
+ operation: faker.helpers.arrayElement(["signEvmMessage"] as const),
122
+ criteria: Array.from(
123
+ { length: faker.number.int({ min: 1, max: 10 }) },
124
+ (_, i) => i + 1,
125
+ ).map(() =>
126
+ faker.helpers.arrayElement([
127
+ { ...getListPoliciesResponseEvmMessageCriterionMock() },
128
+ ]),
129
+ ),
130
+ },
111
131
  {
112
132
  action: faker.helpers.arrayElement(["reject", "accept"] as const),
113
133
  operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
@@ -120,6 +140,10 @@ export const getListPoliciesResponseMock = (): ListPolicies200 => ({
120
140
  ]),
121
141
  ),
122
142
  },
143
+ {
144
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
145
+ operation: faker.helpers.arrayElement(["signEvmHash"] as const),
146
+ },
123
147
  ]),
124
148
  ),
125
149
  createdAt: faker.string.alpha(20),
@@ -165,6 +189,13 @@ export const getCreatePolicyResponseEvmNetworkCriterionMock = (
165
189
  ...overrideResponse,
166
190
  });
167
191
 
192
+ export const getCreatePolicyResponseEvmMessageCriterionMock = (
193
+ overrideResponse: Partial<EvmMessageCriterion> = {},
194
+ ): EvmMessageCriterion => ({
195
+ ...{ type: faker.helpers.arrayElement(["evmMessage"] as const), match: faker.string.alpha(20) },
196
+ ...overrideResponse,
197
+ });
198
+
168
199
  export const getCreatePolicyResponseSolAddressCriterionMock = (
169
200
  overrideResponse: Partial<SolAddressCriterion> = {},
170
201
  ): SolAddressCriterion => ({
@@ -216,6 +247,16 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
216
247
  ]),
217
248
  ),
218
249
  },
250
+ {
251
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
252
+ operation: faker.helpers.arrayElement(["signEvmMessage"] as const),
253
+ criteria: Array.from(
254
+ { length: faker.number.int({ min: 1, max: 10 }) },
255
+ (_, i) => i + 1,
256
+ ).map(() =>
257
+ faker.helpers.arrayElement([{ ...getCreatePolicyResponseEvmMessageCriterionMock() }]),
258
+ ),
259
+ },
219
260
  {
220
261
  action: faker.helpers.arrayElement(["reject", "accept"] as const),
221
262
  operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
@@ -226,6 +267,10 @@ export const getCreatePolicyResponseMock = (overrideResponse: Partial<Policy> =
226
267
  faker.helpers.arrayElement([{ ...getCreatePolicyResponseSolAddressCriterionMock() }]),
227
268
  ),
228
269
  },
270
+ {
271
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
272
+ operation: faker.helpers.arrayElement(["signEvmHash"] as const),
273
+ },
229
274
  ]),
230
275
  ),
231
276
  createdAt: faker.string.alpha(20),
@@ -268,6 +313,13 @@ export const getGetPolicyByIdResponseEvmNetworkCriterionMock = (
268
313
  ...overrideResponse,
269
314
  });
270
315
 
316
+ export const getGetPolicyByIdResponseEvmMessageCriterionMock = (
317
+ overrideResponse: Partial<EvmMessageCriterion> = {},
318
+ ): EvmMessageCriterion => ({
319
+ ...{ type: faker.helpers.arrayElement(["evmMessage"] as const), match: faker.string.alpha(20) },
320
+ ...overrideResponse,
321
+ });
322
+
271
323
  export const getGetPolicyByIdResponseSolAddressCriterionMock = (
272
324
  overrideResponse: Partial<SolAddressCriterion> = {},
273
325
  ): SolAddressCriterion => ({
@@ -319,6 +371,16 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
319
371
  ]),
320
372
  ),
321
373
  },
374
+ {
375
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
376
+ operation: faker.helpers.arrayElement(["signEvmMessage"] as const),
377
+ criteria: Array.from(
378
+ { length: faker.number.int({ min: 1, max: 10 }) },
379
+ (_, i) => i + 1,
380
+ ).map(() =>
381
+ faker.helpers.arrayElement([{ ...getGetPolicyByIdResponseEvmMessageCriterionMock() }]),
382
+ ),
383
+ },
322
384
  {
323
385
  action: faker.helpers.arrayElement(["reject", "accept"] as const),
324
386
  operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
@@ -329,6 +391,10 @@ export const getGetPolicyByIdResponseMock = (overrideResponse: Partial<Policy> =
329
391
  faker.helpers.arrayElement([{ ...getGetPolicyByIdResponseSolAddressCriterionMock() }]),
330
392
  ),
331
393
  },
394
+ {
395
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
396
+ operation: faker.helpers.arrayElement(["signEvmHash"] as const),
397
+ },
332
398
  ]),
333
399
  ),
334
400
  createdAt: faker.string.alpha(20),
@@ -371,6 +437,13 @@ export const getUpdatePolicyResponseEvmNetworkCriterionMock = (
371
437
  ...overrideResponse,
372
438
  });
373
439
 
440
+ export const getUpdatePolicyResponseEvmMessageCriterionMock = (
441
+ overrideResponse: Partial<EvmMessageCriterion> = {},
442
+ ): EvmMessageCriterion => ({
443
+ ...{ type: faker.helpers.arrayElement(["evmMessage"] as const), match: faker.string.alpha(20) },
444
+ ...overrideResponse,
445
+ });
446
+
374
447
  export const getUpdatePolicyResponseSolAddressCriterionMock = (
375
448
  overrideResponse: Partial<SolAddressCriterion> = {},
376
449
  ): SolAddressCriterion => ({
@@ -422,6 +495,16 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
422
495
  ]),
423
496
  ),
424
497
  },
498
+ {
499
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
500
+ operation: faker.helpers.arrayElement(["signEvmMessage"] as const),
501
+ criteria: Array.from(
502
+ { length: faker.number.int({ min: 1, max: 10 }) },
503
+ (_, i) => i + 1,
504
+ ).map(() =>
505
+ faker.helpers.arrayElement([{ ...getUpdatePolicyResponseEvmMessageCriterionMock() }]),
506
+ ),
507
+ },
425
508
  {
426
509
  action: faker.helpers.arrayElement(["reject", "accept"] as const),
427
510
  operation: faker.helpers.arrayElement(["signSolTransaction"] as const),
@@ -432,6 +515,10 @@ export const getUpdatePolicyResponseMock = (overrideResponse: Partial<Policy> =
432
515
  faker.helpers.arrayElement([{ ...getUpdatePolicyResponseSolAddressCriterionMock() }]),
433
516
  ),
434
517
  },
518
+ {
519
+ action: faker.helpers.arrayElement(["reject", "accept"] as const),
520
+ operation: faker.helpers.arrayElement(["signEvmHash"] as const),
521
+ },
435
522
  ]),
436
523
  ),
437
524
  createdAt: faker.string.alpha(20),
@@ -10,6 +10,8 @@ import { faker } from "@faker-js/faker";
10
10
  import { HttpResponse, delay, http } from "msw";
11
11
 
12
12
  import type {
13
+ ExportSolanaAccount200,
14
+ ExportSolanaAccountByName200,
13
15
  ListSolanaAccounts200,
14
16
  SignSolanaMessage200,
15
17
  SignSolanaTransaction200,
@@ -115,6 +117,17 @@ export const getGetSolanaAccountByNameResponseMock = (
115
117
  ...overrideResponse,
116
118
  });
117
119
 
120
+ export const getExportSolanaAccountResponseMock = (
121
+ overrideResponse: Partial<ExportSolanaAccount200> = {},
122
+ ): ExportSolanaAccount200 => ({ encryptedPrivateKey: faker.string.alpha(20), ...overrideResponse });
123
+
124
+ export const getExportSolanaAccountByNameResponseMock = (
125
+ overrideResponse: Partial<ExportSolanaAccountByName200> = {},
126
+ ): ExportSolanaAccountByName200 => ({
127
+ encryptedPrivateKey: faker.string.alpha(20),
128
+ ...overrideResponse,
129
+ });
130
+
118
131
  export const getSignSolanaTransactionResponseMock = (
119
132
  overrideResponse: Partial<SignSolanaTransaction200> = {},
120
133
  ): SignSolanaTransaction200 => ({ signedTransaction: faker.string.alpha(20), ...overrideResponse });
@@ -238,6 +251,52 @@ export const getGetSolanaAccountByNameMockHandler = (
238
251
  });
239
252
  };
240
253
 
254
+ export const getExportSolanaAccountMockHandler = (
255
+ overrideResponse?:
256
+ | ExportSolanaAccount200
257
+ | ((
258
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
259
+ ) => Promise<ExportSolanaAccount200> | ExportSolanaAccount200),
260
+ ) => {
261
+ return http.post("*/v2/solana/accounts/:address/export", async info => {
262
+ await delay(0);
263
+
264
+ return new HttpResponse(
265
+ JSON.stringify(
266
+ overrideResponse !== undefined
267
+ ? typeof overrideResponse === "function"
268
+ ? await overrideResponse(info)
269
+ : overrideResponse
270
+ : getExportSolanaAccountResponseMock(),
271
+ ),
272
+ { status: 200, headers: { "Content-Type": "application/json" } },
273
+ );
274
+ });
275
+ };
276
+
277
+ export const getExportSolanaAccountByNameMockHandler = (
278
+ overrideResponse?:
279
+ | ExportSolanaAccountByName200
280
+ | ((
281
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
282
+ ) => Promise<ExportSolanaAccountByName200> | ExportSolanaAccountByName200),
283
+ ) => {
284
+ return http.post("*/v2/solana/accounts/export/by-name/:name", async info => {
285
+ await delay(0);
286
+
287
+ return new HttpResponse(
288
+ JSON.stringify(
289
+ overrideResponse !== undefined
290
+ ? typeof overrideResponse === "function"
291
+ ? await overrideResponse(info)
292
+ : overrideResponse
293
+ : getExportSolanaAccountByNameResponseMock(),
294
+ ),
295
+ { status: 200, headers: { "Content-Type": "application/json" } },
296
+ );
297
+ });
298
+ };
299
+
241
300
  export const getSignSolanaTransactionMockHandler = (
242
301
  overrideResponse?:
243
302
  | SignSolanaTransaction200
@@ -289,6 +348,8 @@ export const getSolanaAccountsMock = () => [
289
348
  getGetSolanaAccountMockHandler(),
290
349
  getUpdateSolanaAccountMockHandler(),
291
350
  getGetSolanaAccountByNameMockHandler(),
351
+ getExportSolanaAccountMockHandler(),
352
+ getExportSolanaAccountByNameMockHandler(),
292
353
  getSignSolanaTransactionMockHandler(),
293
354
  getSignSolanaMessageMockHandler(),
294
355
  ];
@@ -7,6 +7,10 @@
7
7
  */
8
8
  import type {
9
9
  CreateSolanaAccountBody,
10
+ ExportSolanaAccount200,
11
+ ExportSolanaAccountBody,
12
+ ExportSolanaAccountByName200,
13
+ ExportSolanaAccountByNameBody,
10
14
  ListSolanaAccounts200,
11
15
  ListSolanaAccountsParams,
12
16
  SignSolanaMessage200,
@@ -100,6 +104,44 @@ export const getSolanaAccountByName = (
100
104
  options,
101
105
  );
102
106
  };
107
+ /**
108
+ * Export an existing Solana account's private key. It is important to store the private key in a secure place after it's exported.
109
+ * @summary Export an Solana account
110
+ */
111
+ export const exportSolanaAccount = (
112
+ address: string,
113
+ exportSolanaAccountBody: ExportSolanaAccountBody,
114
+ options?: SecondParameter<typeof cdpApiClient>,
115
+ ) => {
116
+ return cdpApiClient<ExportSolanaAccount200>(
117
+ {
118
+ url: `/v2/solana/accounts/${address}/export`,
119
+ method: "POST",
120
+ headers: { "Content-Type": "application/json" },
121
+ data: exportSolanaAccountBody,
122
+ },
123
+ options,
124
+ );
125
+ };
126
+ /**
127
+ * Export an existing Solana account's private key by its name. It is important to store the private key in a secure place after it's exported.
128
+ * @summary Export a Solana account by name
129
+ */
130
+ export const exportSolanaAccountByName = (
131
+ name: string,
132
+ exportSolanaAccountByNameBody: ExportSolanaAccountByNameBody,
133
+ options?: SecondParameter<typeof cdpApiClient>,
134
+ ) => {
135
+ return cdpApiClient<ExportSolanaAccountByName200>(
136
+ {
137
+ url: `/v2/solana/accounts/export/by-name/${name}`,
138
+ method: "POST",
139
+ headers: { "Content-Type": "application/json" },
140
+ data: exportSolanaAccountByNameBody,
141
+ },
142
+ options,
143
+ );
144
+ };
103
145
  /**
104
146
  * Signs a transaction with the given Solana account.
105
147
  The unsigned transaction should be serialized into a byte array and then encoded as base64.
@@ -160,6 +202,12 @@ export type UpdateSolanaAccountResult = NonNullable<
160
202
  export type GetSolanaAccountByNameResult = NonNullable<
161
203
  Awaited<ReturnType<typeof getSolanaAccountByName>>
162
204
  >;
205
+ export type ExportSolanaAccountResult = NonNullable<
206
+ Awaited<ReturnType<typeof exportSolanaAccount>>
207
+ >;
208
+ export type ExportSolanaAccountByNameResult = NonNullable<
209
+ Awaited<ReturnType<typeof exportSolanaAccountByName>>
210
+ >;
163
211
  export type SignSolanaTransactionResult = NonNullable<
164
212
  Awaited<ReturnType<typeof signSolanaTransaction>>
165
213
  >;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.12.0",
3
+ "version": "1.14.0",
4
4
  "description": "SDK for interacting with the Coinbase Developer Platform Wallet API",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
@@ -107,6 +107,20 @@ export const EvmNetworkCriterionSchema = z.object({
107
107
  });
108
108
  export type EvmNetworkCriterion = z.infer<typeof EvmNetworkCriterionSchema>;
109
109
 
110
+ /**
111
+ * Schema for EVM message criterions
112
+ */
113
+ export const EvmMessageCriterionSchema = z.object({
114
+ /** The type of criterion, must be "evmMessage" for EVM message-based rules. */
115
+ type: z.literal("evmMessage"),
116
+ /**
117
+ * A regular expression the message is matched against.
118
+ * Accepts valid regular expression syntax described by [RE2](https://github.com/google/re2/wiki/Syntax).
119
+ */
120
+ match: z.string().min(1),
121
+ });
122
+ export type EvmMessageCriterion = z.infer<typeof EvmMessageCriterionSchema>;
123
+
110
124
  /**
111
125
  * Schema for Solana address criterions
112
126
  */
@@ -140,6 +154,19 @@ export const SignEvmTransactionCriteriaSchema = z
140
154
  */
141
155
  export type SignEvmTransactionCriteria = z.infer<typeof SignEvmTransactionCriteriaSchema>;
142
156
 
157
+ /**
158
+ * Schema for criteria used in SignEvmMessage operations
159
+ */
160
+ export const SignEvmMessageCriteriaSchema = z
161
+ .array(z.discriminatedUnion("type", [EvmMessageCriterionSchema]))
162
+ .max(10)
163
+ .min(1);
164
+ /**
165
+ * Type representing a set of criteria for the signEvmMessage operation.
166
+ * Can contain up to 10 individual EVM message criterion objects.
167
+ */
168
+ export type SignEvmMessageCriteria = z.infer<typeof SignEvmMessageCriteriaSchema>;
169
+
143
170
  /**
144
171
  * Schema for criteria used in SendEvmTransaction operations
145
172
  */
@@ -226,6 +253,47 @@ export const SignEvmTransactionRuleSchema = z.object({
226
253
  });
227
254
  export type SignEvmTransactionRule = z.infer<typeof SignEvmTransactionRuleSchema>;
228
255
 
256
+ /**
257
+ * Type representing a 'signEvmHash' policy rule that can accept or reject specific operations
258
+ * based on a set of criteria.
259
+ */
260
+ export const SignEvmHashRuleSchema = z.object({
261
+ /**
262
+ * Determines whether matching the rule will cause a request to be rejected or accepted.
263
+ * "accept" will allow the signing, "reject" will block it.
264
+ */
265
+ action: ActionEnum,
266
+ /**
267
+ * The operation to which this rule applies.
268
+ * Must be "signEvmHash".
269
+ */
270
+ operation: z.literal("signEvmHash"),
271
+ });
272
+ export type SignEvmHashRule = z.infer<typeof SignEvmHashRuleSchema>;
273
+
274
+ /**
275
+ * Type representing a 'signEvmMessage' policy rule that can accept or reject specific operations
276
+ * based on a set of criteria.
277
+ */
278
+ export const SignEvmMessageRuleSchema = z.object({
279
+ /**
280
+ * Determines whether matching the rule will cause a request to be rejected or accepted.
281
+ * "accept" will allow the signing, "reject" will block it.
282
+ */
283
+ action: ActionEnum,
284
+ /**
285
+ * The operation to which this rule applies.
286
+ * Must be "signEvmMessage".
287
+ */
288
+ operation: z.literal("signEvmMessage"),
289
+ /**
290
+ * The set of criteria that must be matched for this rule to apply.
291
+ * Must be compatible with the specified operation type.
292
+ */
293
+ criteria: SignEvmMessageCriteriaSchema,
294
+ });
295
+ export type SignEvmMessageRule = z.infer<typeof SignEvmMessageRuleSchema>;
296
+
229
297
  /**
230
298
  * Type representing a 'sendEvmTransaction' policy rule that can accept or reject specific operations
231
299
  * based on a set of criteria.
@@ -277,6 +345,8 @@ export type SignSolTransactionRule = z.infer<typeof SignSolTransactionRuleSchema
277
345
  */
278
346
  export const RuleSchema = z.discriminatedUnion("operation", [
279
347
  SignEvmTransactionRuleSchema,
348
+ SignEvmHashRuleSchema,
349
+ SignEvmMessageRuleSchema,
280
350
  SendEvmTransactionRuleSchema,
281
351
  SignSolTransactionRuleSchema,
282
352
  ]);
package/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.12.0";
1
+ export const version = "1.14.0";