@coinbase/cdp-sdk 1.7.0 → 1.9.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 (226) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +326 -28
  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.map +1 -1
  6. package/_cjs/accounts/solana/toSolanaAccount.js +8 -0
  7. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  8. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +30 -63
  9. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  10. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  11. package/_cjs/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  12. package/_cjs/actions/evm/transfer/transfer.js +2 -39
  13. package/_cjs/actions/evm/transfer/transfer.js.map +1 -1
  14. package/_cjs/actions/evm/transfer/utils.js +0 -12
  15. package/_cjs/actions/evm/transfer/utils.js.map +1 -1
  16. package/_cjs/actions/solana/constants.js +9 -0
  17. package/_cjs/actions/solana/constants.js.map +1 -0
  18. package/_cjs/actions/solana/transfer.js +117 -0
  19. package/_cjs/actions/solana/transfer.js.map +1 -0
  20. package/_cjs/actions/solana/utils.js +66 -0
  21. package/_cjs/actions/solana/utils.js.map +1 -0
  22. package/_cjs/analytics.js +70 -8
  23. package/_cjs/analytics.js.map +1 -1
  24. package/_cjs/client/cdp.js +9 -3
  25. package/_cjs/client/cdp.js.map +1 -1
  26. package/_cjs/client/evm/evm.js +133 -15
  27. package/_cjs/client/evm/evm.js.map +1 -1
  28. package/_cjs/client/policies/index.js +6 -0
  29. package/_cjs/client/policies/index.js.map +1 -0
  30. package/_cjs/client/policies/policies.js +232 -0
  31. package/_cjs/client/policies/policies.js.map +1 -0
  32. package/_cjs/client/policies/policies.types.js +3 -0
  33. package/_cjs/client/policies/policies.types.js.map +1 -0
  34. package/_cjs/client/solana/solana.js +76 -19
  35. package/_cjs/client/solana/solana.js.map +1 -1
  36. package/_cjs/index.js +4 -1
  37. package/_cjs/index.js.map +1 -1
  38. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +35 -4
  39. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  40. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js +27 -1
  41. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  42. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js +56 -1
  43. package/_cjs/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  44. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  45. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  46. package/_cjs/openapi-client/generated/index.msw.js +2 -2
  47. package/_cjs/openapi-client/generated/index.msw.js.map +1 -1
  48. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js +121 -36
  49. package/_cjs/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  50. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js +14 -1
  51. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  52. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js +42 -1
  53. package/_cjs/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  54. package/_cjs/openapi-client/index.js +6 -1
  55. package/_cjs/openapi-client/index.js.map +1 -1
  56. package/_cjs/policies/schema.js +245 -0
  57. package/_cjs/policies/schema.js.map +1 -0
  58. package/_cjs/policies/types.js +3 -0
  59. package/_cjs/policies/types.js.map +1 -0
  60. package/_cjs/version.js +1 -1
  61. package/_esm/accounts/evm/toEvmServerAccount.js +4 -2
  62. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  63. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  64. package/_esm/accounts/solana/toSolanaAccount.js +8 -0
  65. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  66. package/_esm/actions/evm/transfer/accountTransferStrategy.js +31 -64
  67. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  68. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js +39 -56
  69. package/_esm/actions/evm/transfer/smartAccountTransferStrategy.js.map +1 -1
  70. package/_esm/actions/evm/transfer/transfer.js +2 -39
  71. package/_esm/actions/evm/transfer/transfer.js.map +1 -1
  72. package/_esm/actions/evm/transfer/utils.js +0 -11
  73. package/_esm/actions/evm/transfer/utils.js.map +1 -1
  74. package/_esm/actions/solana/constants.js +6 -0
  75. package/_esm/actions/solana/constants.js.map +1 -0
  76. package/_esm/actions/solana/transfer.js +114 -0
  77. package/_esm/actions/solana/transfer.js.map +1 -0
  78. package/_esm/actions/solana/utils.js +61 -0
  79. package/_esm/actions/solana/utils.js.map +1 -0
  80. package/_esm/analytics.js +70 -7
  81. package/_esm/analytics.js.map +1 -1
  82. package/_esm/client/cdp.js +10 -4
  83. package/_esm/client/cdp.js.map +1 -1
  84. package/_esm/client/evm/evm.js +133 -15
  85. package/_esm/client/evm/evm.js.map +1 -1
  86. package/_esm/client/policies/index.js +2 -0
  87. package/_esm/client/policies/index.js.map +1 -0
  88. package/_esm/client/policies/policies.js +228 -0
  89. package/_esm/client/policies/policies.js.map +1 -0
  90. package/_esm/client/policies/policies.types.js +2 -0
  91. package/_esm/client/policies/policies.types.js.map +1 -0
  92. package/_esm/client/solana/solana.js +76 -19
  93. package/_esm/client/solana/solana.js.map +1 -1
  94. package/_esm/index.js +1 -0
  95. package/_esm/index.js.map +1 -1
  96. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +34 -3
  97. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  98. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js +24 -0
  99. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.js.map +1 -1
  100. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js +51 -0
  101. package/_esm/openapi-client/generated/evm-accounts/evm-accounts.msw.js.map +1 -1
  102. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js +3 -1
  103. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.js.map +1 -1
  104. package/_esm/openapi-client/generated/index.msw.js +2 -2
  105. package/_esm/openapi-client/generated/index.msw.js.map +1 -1
  106. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js +116 -35
  107. package/_esm/openapi-client/generated/policy-engine/policy-engine.msw.js.map +1 -1
  108. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js +12 -0
  109. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.js.map +1 -1
  110. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js +39 -0
  111. package/_esm/openapi-client/generated/solana-accounts/solana-accounts.msw.js.map +1 -1
  112. package/_esm/openapi-client/index.js +5 -0
  113. package/_esm/openapi-client/index.js.map +1 -1
  114. package/_esm/policies/schema.js +242 -0
  115. package/_esm/policies/schema.js.map +1 -0
  116. package/_esm/policies/types.js +2 -0
  117. package/_esm/policies/types.js.map +1 -0
  118. package/_esm/version.js +1 -1
  119. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  120. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  121. package/_types/accounts/evm/types.d.ts +6 -3
  122. package/_types/accounts/evm/types.d.ts.map +1 -1
  123. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  124. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts +2 -2
  125. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  126. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts +2 -2
  127. package/_types/actions/evm/transfer/smartAccountTransferStrategy.d.ts.map +1 -1
  128. package/_types/actions/evm/transfer/transfer.d.ts +6 -4
  129. package/_types/actions/evm/transfer/transfer.d.ts.map +1 -1
  130. package/_types/actions/evm/transfer/types.d.ts +8 -54
  131. package/_types/actions/evm/transfer/types.d.ts.map +1 -1
  132. package/_types/actions/evm/transfer/utils.d.ts +0 -619
  133. package/_types/actions/evm/transfer/utils.d.ts.map +1 -1
  134. package/_types/actions/evm/types.d.ts +140 -68
  135. package/_types/actions/evm/types.d.ts.map +1 -1
  136. package/_types/actions/solana/constants.d.ts +6 -0
  137. package/_types/actions/solana/constants.d.ts.map +1 -0
  138. package/_types/actions/solana/transfer.d.ts +36 -0
  139. package/_types/actions/solana/transfer.d.ts.map +1 -0
  140. package/_types/actions/solana/types.d.ts +27 -0
  141. package/_types/actions/solana/types.d.ts.map +1 -1
  142. package/_types/actions/solana/utils.d.ts +34 -0
  143. package/_types/actions/solana/utils.d.ts.map +1 -0
  144. package/_types/analytics.d.ts +14 -5
  145. package/_types/analytics.d.ts.map +1 -1
  146. package/_types/client/cdp.d.ts +3 -0
  147. package/_types/client/cdp.d.ts.map +1 -1
  148. package/_types/client/evm/evm.d.ts +89 -1
  149. package/_types/client/evm/evm.d.ts.map +1 -1
  150. package/_types/client/evm/evm.types.d.ts +33 -3
  151. package/_types/client/evm/evm.types.d.ts.map +1 -1
  152. package/_types/client/policies/index.d.ts +2 -0
  153. package/_types/client/policies/index.d.ts.map +1 -0
  154. package/_types/client/policies/policies.d.ts +216 -0
  155. package/_types/client/policies/policies.d.ts.map +1 -0
  156. package/_types/client/policies/policies.types.d.ts +96 -0
  157. package/_types/client/policies/policies.types.d.ts.map +1 -0
  158. package/_types/client/solana/solana.d.ts +43 -1
  159. package/_types/client/solana/solana.d.ts.map +1 -1
  160. package/_types/client/solana/solana.types.d.ts +14 -2
  161. package/_types/client/solana/solana.types.d.ts.map +1 -1
  162. package/_types/index.d.ts +2 -0
  163. package/_types/index.d.ts.map +1 -1
  164. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +176 -17
  165. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  166. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts +13 -1
  167. package/_types/openapi-client/generated/evm-accounts/evm-accounts.d.ts.map +1 -1
  168. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts +5 -1
  169. package/_types/openapi-client/generated/evm-accounts/evm-accounts.msw.d.ts.map +1 -1
  170. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts +3 -1
  171. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.d.ts.map +1 -1
  172. package/_types/openapi-client/generated/index.msw.d.ts +2 -2
  173. package/_types/openapi-client/generated/index.msw.d.ts.map +1 -1
  174. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts +5 -1
  175. package/_types/openapi-client/generated/policy-engine/policy-engine.msw.d.ts.map +1 -1
  176. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts +7 -1
  177. package/_types/openapi-client/generated/solana-accounts/solana-accounts.d.ts.map +1 -1
  178. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts +2 -0
  179. package/_types/openapi-client/generated/solana-accounts/solana-accounts.msw.d.ts.map +1 -1
  180. package/_types/openapi-client/index.d.ts +18 -0
  181. package/_types/openapi-client/index.d.ts.map +1 -1
  182. package/_types/policies/schema.d.ts +1552 -0
  183. package/_types/policies/schema.d.ts.map +1 -0
  184. package/_types/policies/types.d.ts +19 -0
  185. package/_types/policies/types.d.ts.map +1 -0
  186. package/_types/types/misc.d.ts +39 -0
  187. package/_types/types/misc.d.ts.map +1 -1
  188. package/_types/version.d.ts +1 -1
  189. package/accounts/evm/toEvmServerAccount.ts +11 -7
  190. package/accounts/evm/toEvmSmartAccount.ts +1 -2
  191. package/accounts/evm/types.ts +6 -8
  192. package/accounts/solana/toSolanaAccount.ts +8 -0
  193. package/actions/evm/transfer/accountTransferStrategy.ts +38 -78
  194. package/actions/evm/transfer/smartAccountTransferStrategy.ts +43 -63
  195. package/actions/evm/transfer/transfer.ts +10 -51
  196. package/actions/evm/transfer/types.ts +9 -67
  197. package/actions/evm/transfer/utils.ts +0 -13
  198. package/actions/evm/types.ts +143 -78
  199. package/actions/solana/constants.ts +6 -0
  200. package/actions/solana/transfer.ts +219 -0
  201. package/actions/solana/types.ts +28 -0
  202. package/actions/solana/utils.ts +79 -0
  203. package/analytics.ts +86 -11
  204. package/client/cdp.ts +11 -4
  205. package/client/evm/evm.ts +159 -17
  206. package/client/evm/evm.types.ts +38 -1
  207. package/client/policies/index.ts +1 -0
  208. package/client/policies/policies.ts +246 -0
  209. package/client/policies/policies.types.ts +109 -0
  210. package/client/solana/solana.ts +94 -20
  211. package/client/solana/solana.types.ts +16 -1
  212. package/index.ts +7 -0
  213. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +220 -18
  214. package/openapi-client/generated/evm-accounts/evm-accounts.msw.ts +102 -0
  215. package/openapi-client/generated/evm-accounts/evm-accounts.ts +43 -0
  216. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.ts +3 -1
  217. package/openapi-client/generated/index.msw.ts +2 -2
  218. package/openapi-client/generated/policy-engine/policy-engine.msw.ts +199 -56
  219. package/openapi-client/generated/solana-accounts/solana-accounts.msw.ts +75 -0
  220. package/openapi-client/generated/solana-accounts/solana-accounts.ts +23 -0
  221. package/openapi-client/index.ts +6 -0
  222. package/package.json +4 -2
  223. package/policies/schema.ts +349 -0
  224. package/policies/types.ts +19 -0
  225. package/types/misc.ts +41 -0
  226. package/version.ts +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../policies/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0NH,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":["../../types/misc.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,GAAG,KAAK,MAAM,EAAE,CAAC;AAChC,MAAM,MAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;AACjC,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,SAAS;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,SAAS,GAAG,EAAE,CAAC;CAC7B,EAAE,CAAC;AAEJ,MAAM,MAAM,yBAAyB,GAAG;IACtC,yEAAyE;IACzE,EAAE,EA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1
- export declare const version = "1.7.0";
1
+ export declare const version = "1.9.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
- import { type Hex, type TransactionSerializable, serializeTransaction } from "viem";
1
+ import { type TransactionSerializable, serializeTransaction } from "viem";
2
2
 
3
3
  import {
4
4
  listTokenBalances,
@@ -15,10 +15,12 @@ import { accountTransferStrategy } from "../../actions/evm/transfer/accountTrans
15
15
  import { transfer } from "../../actions/evm/transfer/transfer.js";
16
16
 
17
17
  import type { EvmServerAccount } from "./types.js";
18
- import type { SendTransactionOptions } from "../../actions/evm/sendTransaction.js";
19
- import type { TransferResult } from "../../actions/evm/transfer/types.js";
18
+ import type {
19
+ SendTransactionOptions,
20
+ TransactionResult,
21
+ } from "../../actions/evm/sendTransaction.js";
20
22
  import type { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
21
- import type { Address, Hash } from "../../types/misc.js";
23
+ import type { Address, EIP712Message, Hash, Hex } from "../../types/misc.js";
22
24
 
23
25
  /**
24
26
  * Options for converting a pre-existing EvmAccount to a EvmServerAccount.
@@ -64,10 +66,11 @@ export function toEvmServerAccount(
64
66
  return result.signedTransaction as Hex;
65
67
  },
66
68
 
67
- async signTypedData() {
68
- throw new Error("Not implemented");
69
+ async signTypedData(message: EIP712Message) {
70
+ const result = await apiClient.signEvmTypedData(options.account.address, message);
71
+ return result.signature as Hex;
69
72
  },
70
- async transfer(transferArgs): Promise<TransferResult> {
73
+ async transfer(transferArgs): Promise<TransactionResult> {
71
74
  return transfer(apiClient, account, transferArgs, accountTransferStrategy);
72
75
  },
73
76
  async listTokenBalances(
@@ -94,6 +97,7 @@ export function toEvmServerAccount(
94
97
  },
95
98
  name: options.account.name,
96
99
  type: "evm-server",
100
+ policies: options.account.policies,
97
101
  };
98
102
 
99
103
  return account;
@@ -24,7 +24,6 @@ import {
24
24
  import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
25
25
 
26
26
  import type { EvmAccount, EvmSmartAccount } from "./types.js";
27
- import type { TransferResult } from "../../actions/evm/transfer/types.js";
28
27
  import type {
29
28
  CdpOpenApiClientType,
30
29
  EvmSmartAccount as EvmSmartAccountModel,
@@ -60,7 +59,7 @@ export function toEvmSmartAccount(
60
59
  const account: EvmSmartAccount = {
61
60
  address: options.smartAccount.address as Address,
62
61
  owners: [options.owner],
63
- async transfer(transferArgs): Promise<TransferResult> {
62
+ async transfer(transferArgs): Promise<SendUserOperationReturnType> {
64
63
  return transfer(apiClient, account, transferArgs, smartAccountTransferStrategy);
65
64
  },
66
65
  async listTokenBalances(
@@ -1,9 +1,10 @@
1
- import { SignableMessage, TransactionSerializable, TypedData, TypedDataDefinition } from "viem";
1
+ import { SignableMessage, TransactionSerializable } from "viem";
2
2
 
3
3
  import { Prettify } from "../../types/utils.js";
4
4
 
5
5
  import type { AccountActions, SmartAccountActions } from "../../actions/evm/types.js";
6
- import type { Hash, Hex, Address } from "../../types/misc.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
  /**
@@ -2,6 +2,7 @@ import { Account, SolanaAccount } from "./types.js";
2
2
  import { requestFaucet } from "../../actions/solana/requestFaucet.js";
3
3
  import { signMessage } from "../../actions/solana/signMessage.js";
4
4
  import { signTransaction } from "../../actions/solana/signTransaction.js";
5
+ import { transfer, type TransferOptions } from "../../actions/solana/transfer.js";
5
6
  import {
6
7
  RequestFaucetOptions,
7
8
  SignatureResult,
@@ -53,6 +54,13 @@ export function toSolanaAccount(
53
54
  address: account.address,
54
55
  });
55
56
  },
57
+ policies: options.account.policies,
58
+ async transfer(options: Omit<TransferOptions, "from">): Promise<SignatureResult> {
59
+ return transfer(apiClient, {
60
+ ...options,
61
+ from: account.address,
62
+ });
63
+ },
56
64
  };
57
65
 
58
66
  return account;
@@ -1,88 +1,48 @@
1
- import {
2
- encodeFunctionData,
3
- erc20Abi,
4
- Hex,
5
- TransactionReceipt,
6
- WaitForTransactionReceiptTimeoutError,
7
- } from "viem";
1
+ import { encodeFunctionData, erc20Abi } from "viem";
8
2
 
9
- import { TransferExecutionStrategy } from "./types.js";
10
3
  import { getErc20Address } from "./utils.js";
11
- import { EvmAccount } from "../../../accounts/evm/types.js";
12
4
  import { serializeEIP1559Transaction } from "../../../utils/serializeTransaction.js";
13
5
 
6
+ import type { TransferExecutionStrategy } from "./types.js";
7
+ import type { EvmAccount } from "../../../accounts/evm/types.js";
8
+ import type { TransactionResult } from "../sendTransaction.js";
9
+
14
10
  export const accountTransferStrategy: TransferExecutionStrategy<EvmAccount> = {
15
11
  executeTransfer: async ({ apiClient, from, to, value, token, network }) => {
16
- const transactionHash = await (async () => {
17
- if (token === "eth") {
18
- const result = await apiClient.sendEvmTransaction(from.address, {
19
- transaction: serializeEIP1559Transaction({
20
- value,
21
- to,
22
- }),
23
- network,
24
- });
25
- return result.transactionHash as Hex;
26
- } else {
27
- const erc20Address = getErc20Address(token, network);
28
-
29
- await apiClient.sendEvmTransaction(from.address, {
30
- transaction: serializeEIP1559Transaction({
31
- to: erc20Address,
32
- data: encodeFunctionData({
33
- abi: erc20Abi,
34
- functionName: "approve",
35
- args: [to, value],
36
- }),
37
- }),
38
- network,
39
- });
40
-
41
- const result = await apiClient.sendEvmTransaction(from.address, {
42
- transaction: serializeEIP1559Transaction({
43
- to: erc20Address,
44
- data: encodeFunctionData({
45
- abi: erc20Abi,
46
- functionName: "transfer",
47
- args: [to, value],
48
- }),
49
- }),
50
- network,
51
- });
52
-
53
- return result.transactionHash as Hex;
54
- }
55
- })();
56
-
57
- return transactionHash;
58
- },
59
-
60
- waitForResult: async ({ publicClient, hash, waitOptions }) => {
61
- let receipt: TransactionReceipt;
62
- try {
63
- receipt = await publicClient.waitForTransactionReceipt({
64
- hash,
65
- pollingInterval: waitOptions?.intervalSeconds
66
- ? waitOptions.intervalSeconds * 1000
67
- : undefined,
68
- timeout: waitOptions?.timeoutSeconds ? waitOptions.timeoutSeconds * 1000 : undefined,
69
- });
70
- } catch (error) {
71
- if (error instanceof WaitForTransactionReceiptTimeoutError) {
72
- throw new Error(
73
- `Transaction timed out. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
74
- );
75
- } else {
76
- throw error;
77
- }
12
+ if (token === "eth") {
13
+ return apiClient.sendEvmTransaction(from.address, {
14
+ transaction: serializeEIP1559Transaction({
15
+ value,
16
+ to,
17
+ }),
18
+ network,
19
+ }) as Promise<TransactionResult>;
78
20
  }
79
21
 
80
- if (receipt.status === "success") {
81
- return { status: receipt.status, transactionHash: hash };
82
- } else {
83
- throw new Error(
84
- `Transaction failed. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
85
- );
86
- }
22
+ const erc20Address = getErc20Address(token, network);
23
+
24
+ await apiClient.sendEvmTransaction(from.address, {
25
+ transaction: serializeEIP1559Transaction({
26
+ to: erc20Address,
27
+ data: encodeFunctionData({
28
+ abi: erc20Abi,
29
+ functionName: "approve",
30
+ args: [to, value],
31
+ }),
32
+ }),
33
+ network,
34
+ });
35
+
36
+ return apiClient.sendEvmTransaction(from.address, {
37
+ transaction: serializeEIP1559Transaction({
38
+ to: erc20Address,
39
+ data: encodeFunctionData({
40
+ abi: erc20Abi,
41
+ functionName: "transfer",
42
+ args: [to, value],
43
+ }),
44
+ }),
45
+ network,
46
+ }) as Promise<TransactionResult>;
87
47
  },
88
48
  };
@@ -1,75 +1,55 @@
1
1
  import { encodeFunctionData, erc20Abi } from "viem";
2
2
 
3
- import { TransferExecutionStrategy } from "./types.js";
4
3
  import { getErc20Address } from "./utils.js";
5
- import { EvmSmartAccount } from "../../../accounts/evm/types.js";
6
4
  import { sendUserOperation } from "../sendUserOperation.js";
7
- import { waitForUserOperation } from "../waitForUserOperation.js";
5
+
6
+ import type { TransferExecutionStrategy } from "./types.js";
7
+ import type { EvmSmartAccount } from "../../../accounts/evm/types.js";
8
8
 
9
9
  export const smartAccountTransferStrategy: TransferExecutionStrategy<EvmSmartAccount> = {
10
10
  executeTransfer: async ({ apiClient, from, to, value, token, network, paymasterUrl }) => {
11
- const userOpHash = await (async () => {
12
- if (token === "eth") {
13
- const result = await sendUserOperation(apiClient, {
14
- smartAccount: from,
15
- paymasterUrl,
16
- network,
17
- calls: [
18
- {
19
- to,
20
- value,
21
- data: "0x",
22
- },
23
- ],
24
- });
25
- return result.userOpHash;
26
- } else {
27
- const erc20Address = getErc20Address(token, network);
28
-
29
- const result = await sendUserOperation(apiClient, {
30
- smartAccount: from,
31
- paymasterUrl,
32
- network,
33
- calls: [
34
- {
35
- to: erc20Address,
36
- data: encodeFunctionData({
37
- abi: erc20Abi,
38
- functionName: "approve",
39
- args: [to, value],
40
- }),
41
- },
42
- {
43
- to: erc20Address,
44
- data: encodeFunctionData({
45
- abi: erc20Abi,
46
- functionName: "transfer",
47
- args: [to, value],
48
- }),
49
- },
50
- ],
51
- });
52
-
53
- return result.userOpHash;
54
- }
55
- })();
56
-
57
- return userOpHash;
58
- },
11
+ if (token === "eth") {
12
+ const result = await sendUserOperation(apiClient, {
13
+ smartAccount: from,
14
+ paymasterUrl,
15
+ network,
16
+ calls: [
17
+ {
18
+ to,
19
+ value,
20
+ data: "0x",
21
+ },
22
+ ],
23
+ });
24
+ return result;
25
+ } else {
26
+ const erc20Address = getErc20Address(token, network);
59
27
 
60
- waitForResult: async ({ apiClient, publicClient, from, hash, waitOptions }) => {
61
- const result = await waitForUserOperation(apiClient, {
62
- smartAccountAddress: from.address,
63
- userOpHash: hash,
64
- waitOptions,
65
- });
28
+ const result = await sendUserOperation(apiClient, {
29
+ smartAccount: from,
30
+ paymasterUrl,
31
+ network,
32
+ calls: [
33
+ {
34
+ to: erc20Address,
35
+ data: encodeFunctionData({
36
+ abi: erc20Abi,
37
+ functionName: "approve",
38
+ args: [to, value],
39
+ }),
40
+ },
41
+ {
42
+ to: erc20Address,
43
+ data: encodeFunctionData({
44
+ abi: erc20Abi,
45
+ functionName: "transfer",
46
+ args: [to, value],
47
+ }),
48
+ },
49
+ ],
50
+ });
66
51
 
67
- if (result.status === "complete") {
68
- return { status: "success", transactionHash: hash };
69
- } else {
70
- throw new Error(
71
- `Transaction failed. Check the transaction on the explorer: ${publicClient.chain.blockExplorers?.default.url}/tx/${hash}`,
72
- );
52
+ return result;
73
53
  }
74
54
  },
75
55
  };
@@ -1,15 +1,13 @@
1
- import { createPublicClient, http, erc20Abi, parseUnits, Address, Chain, Transport } from "viem";
2
-
3
- import { mapNetworkToChain } from "./utils.js";
4
- import { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
5
- import { CdpOpenApiClientType } from "../../../openapi-client/index.js";
6
-
7
1
  import type {
8
- TransferResult,
9
2
  TransferExecutionStrategy,
10
3
  SmartAccountTransferOptions,
11
- AccountTransferOptions,
4
+ TransferOptions,
12
5
  } from "./types.js";
6
+ import type { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
7
+ import type { CdpOpenApiClientType } from "../../../openapi-client/index.js";
8
+ import type { Address } from "../../../types/misc.js";
9
+ import type { TransactionResult } from "../sendTransaction.js";
10
+ import type { SendUserOperationReturnType } from "../sendUserOperation.js";
13
11
 
14
12
  /**
15
13
  * Transfer an amount of a token from an account to another account.
@@ -23,60 +21,21 @@ import type {
23
21
  export async function transfer<T extends EvmAccount | EvmSmartAccount>(
24
22
  apiClient: CdpOpenApiClientType,
25
23
  from: T,
26
- transferArgs: T extends EvmSmartAccount ? SmartAccountTransferOptions : AccountTransferOptions,
24
+ transferArgs: T extends EvmSmartAccount ? SmartAccountTransferOptions : TransferOptions,
27
25
  transferStrategy: TransferExecutionStrategy<T>,
28
- ): Promise<TransferResult> {
29
- const publicClient = createPublicClient<Transport, Chain>({
30
- chain: mapNetworkToChain(transferArgs.network),
31
- transport: http(),
32
- });
33
-
26
+ ): Promise<T extends EvmSmartAccount ? SendUserOperationReturnType : TransactionResult> {
34
27
  const to =
35
28
  typeof transferArgs.to === "string" ? transferArgs.to : (transferArgs.to.address as Address);
36
29
 
37
- const value = await (async () => {
38
- // user supplied a bigint. otherwise, we need to convert the amount to a bigint
39
- if (typeof transferArgs.amount !== "string") {
40
- return transferArgs.amount;
41
- }
42
-
43
- const decimals = await (async () => {
44
- if (transferArgs.token === "eth") {
45
- return 18;
46
- } else if (transferArgs.token === "usdc") {
47
- return 6;
48
- } else {
49
- return publicClient.readContract({
50
- address: transferArgs.token,
51
- abi: erc20Abi,
52
- functionName: "decimals",
53
- args: [],
54
- });
55
- }
56
- })();
57
-
58
- return parseUnits(transferArgs.amount, decimals);
59
- })();
60
-
61
30
  const transfer = {
62
31
  apiClient,
63
32
  from,
64
33
  to,
65
- value,
34
+ value: transferArgs.amount,
66
35
  token: transferArgs.token,
67
36
  network: transferArgs.network,
68
37
  paymasterUrl: "paymasterUrl" in transferArgs ? transferArgs.paymasterUrl : undefined,
69
38
  };
70
39
 
71
- const hash = await transferStrategy.executeTransfer(transfer);
72
-
73
- const result = await transferStrategy.waitForResult({
74
- apiClient,
75
- publicClient,
76
- from,
77
- hash,
78
- waitOptions: transferArgs.waitOptions,
79
- });
80
-
81
- return result;
40
+ return transferStrategy.executeTransfer(transfer);
82
41
  }
@@ -1,21 +1,12 @@
1
- import {
2
- Hex,
3
- TransactionReceipt,
4
- Address,
5
- PublicClient,
6
- Chain,
7
- Transport,
8
- WaitForTransactionReceiptParameters,
9
- } from "viem";
10
-
11
- import {
1
+ import type { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
2
+ import type {
12
3
  CdpOpenApiClientType,
13
4
  EvmUserOperationNetwork,
14
5
  SendEvmTransactionBodyNetwork,
15
6
  } from "../../../openapi-client/index.js";
16
-
17
- import type { EvmAccount, EvmSmartAccount } from "../../../accounts/evm/types.js";
18
- import type { WaitForUserOperationOptions } from "../waitForUserOperation.js";
7
+ import type { TransactionResult } from "../sendTransaction.js";
8
+ import type { SendUserOperationReturnType } from "../sendUserOperation.js";
9
+ import type { Hex, Address } from "viem";
19
10
 
20
11
  /**
21
12
  * The network to transfer the token on.
@@ -25,55 +16,25 @@ export type Network = SendEvmTransactionBodyNetwork | EvmUserOperationNetwork;
25
16
  /**
26
17
  * The options for the transfer.
27
18
  */
28
- type TransferOptions = {
19
+ export type TransferOptions = {
29
20
  /** The account to transfer the token to. */
30
21
  to: EvmAccount | Address;
31
22
  /**
32
- * The amount of the token to transfer.
33
- * If a string is provided, it will be parsed into a bigint based on the token's decimals.
23
+ * The amount of the token to transfer, represented as an atomic value.
34
24
  */
35
- amount: bigint | string;
25
+ amount: bigint;
36
26
  /** The token to transfer. Can be a contract address or a predefined token name. */
37
27
  token: "eth" | "usdc" | Hex;
38
28
  /** The network to transfer the token on. */
39
29
  network: Network;
40
30
  };
41
31
 
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
32
  /**
60
33
  * The options for the transfer using a smart account.
61
34
  */
62
35
  export type SmartAccountTransferOptions = TransferOptions & {
63
36
  /** The paymaster URL to use for the transfer. */
64
37
  paymasterUrl?: string;
65
- /** The options for waiting for the result of the transfer. */
66
- waitOptions?: WaitForUserOperationOptions["waitOptions"];
67
- };
68
-
69
- /**
70
- * The result of the transfer.
71
- */
72
- export type TransferResult = {
73
- /** The status of the transaction. */
74
- status: TransactionReceipt["status"];
75
- /** The transaction hash of the transfer. */
76
- transactionHash: Hex;
77
38
  };
78
39
 
79
40
  /**
@@ -101,24 +62,5 @@ export interface TransferExecutionStrategy<T extends EvmAccount | EvmSmartAccoun
101
62
  token: TransferOptions["token"];
102
63
  network: TransferOptions["network"];
103
64
  } & (T extends EvmSmartAccount ? { paymasterUrl?: string } : object),
104
- ): Promise<Hex>;
105
-
106
- /**
107
- * Waits for the result of the transfer.
108
- *
109
- * @param args - The arguments for the transfer.
110
- * @param args.apiClient - The API client to use for the transfer.
111
- * @param args.publicClient - The public client to use for the transfer.
112
- * @param args.from - The account to transfer the token from.
113
- * @param args.hash - The transaction hash of the transfer.
114
- * @param args.waitOptions - The options for waiting for the result of the transfer.
115
- * @returns The result of the transfer.
116
- */
117
- waitForResult(args: {
118
- apiClient: CdpOpenApiClientType;
119
- publicClient: PublicClient<Transport, Chain>;
120
- from: T;
121
- hash: Hex;
122
- waitOptions?: WaitForUserOperationOptions["waitOptions"];
123
- }): Promise<TransferResult>;
65
+ ): Promise<T extends EvmSmartAccount ? SendUserOperationReturnType : TransactionResult>;
124
66
  }