@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.6.0",
3
+ "version": "1.8.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",
@@ -23,7 +23,8 @@
23
23
  "axios": "^1.8.2",
24
24
  "jose": "^6.0.8",
25
25
  "md5": "^2.3.0",
26
- "viem": "^2.21.26"
26
+ "viem": "^2.21.26",
27
+ "zod": "^3.24.4"
27
28
  },
28
29
  "author": "Coinbase Inc.",
29
30
  "repository": "https://github.com/coinbase/cdp-sdk",
@@ -0,0 +1,266 @@
1
+ import { Address } from "abitype/zod";
2
+ import { z } from "zod";
3
+
4
+ /**
5
+ * Enum for EthValueOperator values
6
+ */
7
+ export const EthValueOperatorEnum = z.enum([">", ">=", "<", "<=", "=="]);
8
+ /**
9
+ * Type representing the operators that can be used for ETH value comparisons.
10
+ * These operators determine how transaction values are compared against thresholds.
11
+ */
12
+ export type EthValueOperator = z.infer<typeof EthValueOperatorEnum>;
13
+
14
+ /**
15
+ * Enum for EvmAddressOperator values
16
+ */
17
+ export const EvmAddressOperatorEnum = z.enum(["in", "not in"]);
18
+ /**
19
+ * Type representing the operators that can be used for EVM address comparisons.
20
+ * These operators determine how transaction recipient addresses are evaluated against a list.
21
+ */
22
+ export type EvmAddressOperator = z.infer<typeof EvmAddressOperatorEnum>;
23
+
24
+ /**
25
+ * Enum for SolAddressOperator values
26
+ */
27
+ export const SolAddressOperatorEnum = z.enum(["in", "not in"]);
28
+ /**
29
+ * Type representing the operators that can be used for Solana address comparisons.
30
+ * These operators determine how transaction addresses are evaluated against a list.
31
+ */
32
+ export type SolAddressOperator = z.infer<typeof SolAddressOperatorEnum>;
33
+
34
+ /**
35
+ * Schema for ETH value criterions
36
+ */
37
+ export const EthValueCriterionSchema = z.object({
38
+ /** The type of criterion, must be "ethValue" for Ethereum value-based rules. */
39
+ type: z.literal("ethValue"),
40
+ /**
41
+ * The ETH value amount in wei to compare against, as a string.
42
+ * Must contain only digits.
43
+ */
44
+ ethValue: z.string().regex(/^[0-9]+$/),
45
+ /** The comparison operator to use for evaluating transaction values against the threshold. */
46
+ operator: EthValueOperatorEnum,
47
+ });
48
+ export type EthValueCriterion = z.infer<typeof EthValueCriterionSchema>;
49
+
50
+ /**
51
+ * Schema for EVM address criterions
52
+ */
53
+ export const EvmAddressCriterionSchema = z.object({
54
+ /** The type of criterion, must be "evmAddress" for EVM address-based rules. */
55
+ type: z.literal("evmAddress"),
56
+ /**
57
+ * Array of EVM addresses to compare against.
58
+ * Each address must be a 0x-prefixed 40-character hexadecimal string.
59
+ * Limited to a maximum of 100 addresses per criterion.
60
+ */
61
+ addresses: z.array(Address).max(100),
62
+ /**
63
+ * The operator to use for evaluating transaction addresses.
64
+ * "in" checks if an address is in the provided list.
65
+ * "not in" checks if an address is not in the provided list.
66
+ */
67
+ operator: EvmAddressOperatorEnum,
68
+ });
69
+ export type EvmAddressCriterion = z.infer<typeof EvmAddressCriterionSchema>;
70
+
71
+ /**
72
+ * Schema for Solana address criterions
73
+ */
74
+ export const SolAddressCriterionSchema = z.object({
75
+ /** The type of criterion, must be "solAddress" for Solana address-based rules. */
76
+ type: z.literal("solAddress"),
77
+ /**
78
+ * Array of Solana addresses to compare against.
79
+ * Each address must be a valid Base58-encoded Solana address (32-44 characters).
80
+ */
81
+ addresses: z.array(z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/)),
82
+ /**
83
+ * The operator to use for evaluating transaction addresses.
84
+ * "in" checks if an address is in the provided list.
85
+ * "not in" checks if an address is not in the provided list.
86
+ */
87
+ operator: SolAddressOperatorEnum,
88
+ });
89
+ export type SolAddressCriterion = z.infer<typeof SolAddressCriterionSchema>;
90
+
91
+ /**
92
+ * Schema for criteria used in SignEvmTransaction operations
93
+ */
94
+ export const SignEvmTransactionCriteriaSchema = z
95
+ .array(z.discriminatedUnion("type", [EthValueCriterionSchema, EvmAddressCriterionSchema]))
96
+ .max(10)
97
+ .min(1);
98
+ /**
99
+ * Type representing a set of criteria for the signEvmTransaction operation.
100
+ * Can contain up to 10 individual criterion objects of ETH value or EVM address types.
101
+ */
102
+ export type SignEvmTransactionCriteria = z.infer<typeof SignEvmTransactionCriteriaSchema>;
103
+
104
+ /**
105
+ * Schema for criteria used in SignSolTransaction operations
106
+ */
107
+ export const SignSolTransactionCriteriaSchema = z
108
+ .array(z.discriminatedUnion("type", [SolAddressCriterionSchema]))
109
+ .max(10)
110
+ .min(1);
111
+ /**
112
+ * Type representing a set of criteria for the signSolTransaction operation.
113
+ * Can contain up to 10 individual Solana address criterion objects.
114
+ */
115
+ export type SignSolTransactionCriteria = z.infer<typeof SignSolTransactionCriteriaSchema>;
116
+
117
+ /**
118
+ * Enum for Solana Operation types
119
+ */
120
+ export const SolOperationEnum = z.enum(["signSolTransaction"]);
121
+ /**
122
+ * Type representing the operations that can be governed by a policy.
123
+ * Defines what Solana operations the policy applies to.
124
+ */
125
+ export type SolOperation = z.infer<typeof SolOperationEnum>;
126
+
127
+ /**
128
+ * Enum for Evm Operation types
129
+ */
130
+ export const EvmOperationEnum = z.enum(["signEvmTransaction"]);
131
+ /**
132
+ * Type representing the operations that can be governed by a policy.
133
+ * Defines what EVM operations the policy applies to.
134
+ */
135
+ export type EvmOperation = z.infer<typeof EvmOperationEnum>;
136
+
137
+ /**
138
+ * Enum for Action types
139
+ */
140
+ export const ActionEnum = z.enum(["reject", "accept"]);
141
+ /**
142
+ * Type representing the possible policy actions.
143
+ * Determines whether matching the rule will cause a request to be accepted or rejected.
144
+ */
145
+ export type Action = z.infer<typeof ActionEnum>;
146
+
147
+ /**
148
+ * Type representing a 'signEvmTransaction' policy rule that can accept or reject specific operations
149
+ * based on a set of criteria.
150
+ */
151
+ export const SignEvmTransactionRuleSchema = z.object({
152
+ /**
153
+ * Determines whether matching the rule will cause a request to be rejected or accepted.
154
+ * "accept" will allow the transaction, "reject" will block it.
155
+ */
156
+ action: ActionEnum,
157
+ /**
158
+ * The operation to which this rule applies.
159
+ * Must be "signEvmTransaction".
160
+ */
161
+ operation: z.literal("signEvmTransaction"),
162
+ /**
163
+ * The set of criteria that must be matched for this rule to apply.
164
+ * Must be compatible with the specified operation type.
165
+ */
166
+ criteria: SignEvmTransactionCriteriaSchema,
167
+ });
168
+ export type SignEvmTransactionRule = z.infer<typeof SignEvmTransactionRuleSchema>;
169
+
170
+ /**
171
+ * Type representing a 'signSolTransaction' policy rule that can accept or reject specific operations
172
+ * based on a set of criteria.
173
+ */
174
+ export const SignSolTransactionRuleSchema = z.object({
175
+ /**
176
+ * Determines whether matching the rule will cause a request to be rejected or accepted.
177
+ * "accept" will allow the transaction, "reject" will block it.
178
+ */
179
+ action: ActionEnum,
180
+ /**
181
+ * The operation to which this rule applies.
182
+ * Must be "signSolTransaction".
183
+ */
184
+ operation: z.literal("signSolTransaction"),
185
+ /**
186
+ * The set of criteria that must be matched for this rule to apply.
187
+ * Must be compatible with the specified operation type.
188
+ */
189
+ criteria: SignSolTransactionCriteriaSchema,
190
+ });
191
+ export type SignSolTransactionRule = z.infer<typeof SignSolTransactionRuleSchema>;
192
+
193
+ /**
194
+ * Schema for policy rules
195
+ */
196
+ export const RuleSchema = z.discriminatedUnion("operation", [
197
+ SignEvmTransactionRuleSchema,
198
+ SignSolTransactionRuleSchema,
199
+ ]);
200
+
201
+ /**
202
+ * Type representing a policy rule that can accept or reject specific operations
203
+ * based on a set of criteria.
204
+ */
205
+ export type Rule = z.infer<typeof RuleSchema>;
206
+
207
+ /**
208
+ * Enum for policy scopes
209
+ */
210
+ export const PolicyScopeEnum = z.enum(["project", "account"]);
211
+ /**
212
+ * Type representing the scope of a policy.
213
+ * Determines whether the policy applies at the project level or account level.
214
+ */
215
+ export type PolicyScope = z.infer<typeof PolicyScopeEnum>;
216
+
217
+ /**
218
+ * Schema for creating or updating a Policy.
219
+ */
220
+ export const CreatePolicyBodySchema = z.object({
221
+ /**
222
+ * The scope of the policy.
223
+ * "project" applies to the entire project, "account" applies to specific accounts.
224
+ */
225
+ scope: PolicyScopeEnum,
226
+ /**
227
+ * An optional human-readable description for the policy.
228
+ * Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.
229
+ */
230
+ description: z
231
+ .string()
232
+ .regex(/^[A-Za-z0-9 ,.]{1,50}$/)
233
+ .optional(),
234
+ /**
235
+ * Array of rules that comprise the policy.
236
+ * Limited to a maximum of 10 rules per policy.
237
+ */
238
+ rules: z.array(RuleSchema).max(10).min(1),
239
+ });
240
+ /**
241
+ * Type representing the request body for creating a new policy.
242
+ * Contains the scope, optional description, and rules for the policy.
243
+ */
244
+ export type CreatePolicyBody = z.infer<typeof CreatePolicyBodySchema>;
245
+
246
+ export const UpdatePolicyBodySchema = z.object({
247
+ /**
248
+ * An optional human-readable description for the policy.
249
+ * Limited to 50 characters of alphanumeric characters, spaces, commas, and periods.
250
+ */
251
+ description: z
252
+ .string()
253
+ .regex(/^[A-Za-z0-9 ,.]{1,50}$/)
254
+ .optional(),
255
+ /**
256
+ * Array of rules that comprise the policy.
257
+ * Limited to a maximum of 10 rules per policy.
258
+ */
259
+ rules: z.array(RuleSchema).max(10).min(1),
260
+ });
261
+ /**
262
+ * Type representing the request body for updating an existing policy.
263
+ * Contains the optional description and rules for the updated policy.
264
+ * Note that the scope cannot be changed once a policy is created.
265
+ */
266
+ export type UpdatePolicyBody = z.infer<typeof UpdatePolicyBodySchema>;
@@ -0,0 +1,19 @@
1
+ import { PolicyScope, Rule } from "./schema.js";
2
+
3
+ /**
4
+ * A single Policy that can be used to govern the behavior of projects and accounts.
5
+ */
6
+ export type Policy = {
7
+ /** The unique identifier for the policy. */
8
+ id: string;
9
+ /** An optional human-readable description of the policy. */
10
+ description?: string;
11
+ /** The scope of the policy. Only one project-level policy can exist at any time. */
12
+ scope: PolicyScope;
13
+ /** A list of rules that comprise the policy. */
14
+ rules: Rule[];
15
+ /** The ISO 8601 timestamp at which the Policy was created. */
16
+ createdAt: string;
17
+ /** The ISO 8601 timestamp at which the Policy was last updated. */
18
+ updatedAt: string;
19
+ };
package/types/misc.ts CHANGED
@@ -42,3 +42,44 @@ export type TransactionRequestEIP1559 = {
42
42
  /** (Ignored) The transaction type is always `eip1559`. */
43
43
  type?: "eip1559" | undefined;
44
44
  };
45
+
46
+ /**
47
+ * The domain of the EIP-712 typed data.
48
+ */
49
+ export interface EIP712Domain {
50
+ /** The name of the DApp or protocol. */
51
+ name?: string;
52
+ /** The version of the DApp or protocol. */
53
+ version?: string;
54
+ /** The chain ID of the EVM network. */
55
+ chainId?: number;
56
+ /** The 0x-prefixed EVM address of the verifying smart contract. */
57
+ verifyingContract?: string;
58
+ /** The optional 32-byte 0x-prefixed hex salt for domain separation. */
59
+ salt?: string;
60
+ }
61
+
62
+ /**
63
+ * A mapping of struct names to an array of type objects (name + type).
64
+ * Each key corresponds to a type name (e.g., "`EIP712Domain`", "`PermitTransferFrom`").
65
+ */
66
+ export interface EIP712Types {
67
+ [key: string]: unknown;
68
+ }
69
+
70
+ /**
71
+ * The message to sign. The structure of this message must match the `primaryType` struct in the `types` object.
72
+ */
73
+ export type EIP712MessageMessage = { [key: string]: unknown };
74
+
75
+ /**
76
+ * The message to sign using EIP-712.
77
+ */
78
+ export interface EIP712Message {
79
+ domain: EIP712Domain;
80
+ types: EIP712Types;
81
+ /** The primary type of the message. This is the name of the struct in the `types` object that is the root of the message. */
82
+ primaryType: string;
83
+ /** The message to sign. The structure of this message must match the `primaryType` struct in the `types` object. */
84
+ message: EIP712MessageMessage;
85
+ }
package/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.6.0";
1
+ export const version = "1.8.0";
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,iCAAiC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,sEAAsE;IACtE,IAAI,EAAE,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACnD,iEAAiE;IACjE,WAAW,EAAE,CAAC,UAAU,EAAE;QAAE,OAAO,EAAE,eAAe,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxE,8EAA8E;IAC9E,eAAe,EAAE,CAAC,WAAW,EAAE,uBAAuB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxE,oEAAoE;IACpE,aAAa,EAAE,CACb,KAAK,CAAC,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,SAAS,EAEtE,UAAU,EAAE,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,KACpD,OAAO,CAAC,GAAG,CAAC,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACrC,UAAU,GACR,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,sBAAsB,CAAC,GAAG;IAC5D,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,IAAI,EAAE,YAAY,CAAC;CACpB,CACJ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,CACpC;IACE,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uKAAuK;IACvK,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,6CAA6C;IAC7C,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,CACrC,CAAC"}
File without changes
File without changes