@coinbase/cdp-sdk 1.14.0 → 1.16.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 (98) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +113 -20
  3. package/_cjs/accounts/evm/toEvmServerAccount.js +13 -7
  4. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  5. package/_cjs/accounts/evm/toEvmSmartAccount.js +18 -0
  6. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  7. package/_cjs/actions/evm/signAndWrapTypedDataForSmartAccount.js +186 -0
  8. package/_cjs/actions/evm/signAndWrapTypedDataForSmartAccount.js.map +1 -0
  9. package/_cjs/actions/evm/swap/createSwapQuote.js +26 -8
  10. package/_cjs/actions/evm/swap/createSwapQuote.js.map +1 -1
  11. package/_cjs/actions/evm/swap/getSwapPrice.js +3 -2
  12. package/_cjs/actions/evm/swap/getSwapPrice.js.map +1 -1
  13. package/_cjs/actions/evm/swap/sendSwapOperation.js +153 -0
  14. package/_cjs/actions/evm/swap/sendSwapOperation.js.map +1 -0
  15. package/_cjs/actions/evm/swap/sendSwapTransaction.js +16 -2
  16. package/_cjs/actions/evm/swap/sendSwapTransaction.js.map +1 -1
  17. package/_cjs/client/evm/evm.js +56 -6
  18. package/_cjs/client/evm/evm.js.map +1 -1
  19. package/_cjs/client/solana/solana.js +43 -0
  20. package/_cjs/client/solana/solana.js.map +1 -1
  21. package/_cjs/utils/export.js +84 -0
  22. package/_cjs/utils/export.js.map +1 -0
  23. package/_cjs/utils/uuidV4.js +26 -0
  24. package/_cjs/utils/uuidV4.js.map +1 -0
  25. package/_cjs/version.js +1 -1
  26. package/_esm/accounts/evm/toEvmServerAccount.js +14 -8
  27. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  28. package/_esm/accounts/evm/toEvmSmartAccount.js +18 -0
  29. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  30. package/_esm/actions/evm/signAndWrapTypedDataForSmartAccount.js +181 -0
  31. package/_esm/actions/evm/signAndWrapTypedDataForSmartAccount.js.map +1 -0
  32. package/_esm/actions/evm/swap/createSwapQuote.js +26 -8
  33. package/_esm/actions/evm/swap/createSwapQuote.js.map +1 -1
  34. package/_esm/actions/evm/swap/getSwapPrice.js +3 -2
  35. package/_esm/actions/evm/swap/getSwapPrice.js.map +1 -1
  36. package/_esm/actions/evm/swap/sendSwapOperation.js +150 -0
  37. package/_esm/actions/evm/swap/sendSwapOperation.js.map +1 -0
  38. package/_esm/actions/evm/swap/sendSwapTransaction.js +16 -2
  39. package/_esm/actions/evm/swap/sendSwapTransaction.js.map +1 -1
  40. package/_esm/client/evm/evm.js +58 -8
  41. package/_esm/client/evm/evm.js.map +1 -1
  42. package/_esm/client/solana/solana.js +43 -0
  43. package/_esm/client/solana/solana.js.map +1 -1
  44. package/_esm/utils/export.js +75 -0
  45. package/_esm/utils/export.js.map +1 -0
  46. package/_esm/utils/uuidV4.js +23 -0
  47. package/_esm/utils/uuidV4.js.map +1 -0
  48. package/_esm/version.js +1 -1
  49. package/_types/accounts/evm/toEvmServerAccount.d.ts.map +1 -1
  50. package/_types/accounts/evm/toEvmSmartAccount.d.ts.map +1 -1
  51. package/_types/accounts/evm/types.d.ts +4 -4
  52. package/_types/accounts/evm/types.d.ts.map +1 -1
  53. package/_types/actions/evm/signAndWrapTypedDataForSmartAccount.d.ts +133 -0
  54. package/_types/actions/evm/signAndWrapTypedDataForSmartAccount.d.ts.map +1 -0
  55. package/_types/actions/evm/swap/createSwapQuote.d.ts.map +1 -1
  56. package/_types/actions/evm/swap/getSwapPrice.d.ts +2 -1
  57. package/_types/actions/evm/swap/getSwapPrice.d.ts.map +1 -1
  58. package/_types/actions/evm/swap/sendSwapOperation.d.ts +64 -0
  59. package/_types/actions/evm/swap/sendSwapOperation.d.ts.map +1 -0
  60. package/_types/actions/evm/swap/sendSwapTransaction.d.ts.map +1 -1
  61. package/_types/actions/evm/swap/types.d.ts +131 -5
  62. package/_types/actions/evm/swap/types.d.ts.map +1 -1
  63. package/_types/actions/evm/types.d.ts +112 -21
  64. package/_types/actions/evm/types.d.ts.map +1 -1
  65. package/_types/client/cdp.d.ts +1 -2
  66. package/_types/client/cdp.d.ts.map +1 -1
  67. package/_types/client/evm/evm.d.ts +29 -3
  68. package/_types/client/evm/evm.d.ts.map +1 -1
  69. package/_types/client/evm/evm.types.d.ts +45 -7
  70. package/_types/client/evm/evm.types.d.ts.map +1 -1
  71. package/_types/client/solana/solana.d.ts +26 -1
  72. package/_types/client/solana/solana.d.ts.map +1 -1
  73. package/_types/client/solana/solana.types.d.ts +12 -0
  74. package/_types/client/solana/solana.types.d.ts.map +1 -1
  75. package/_types/utils/export.d.ts +30 -0
  76. package/_types/utils/export.d.ts.map +1 -0
  77. package/_types/utils/uuidV4.d.ts +10 -0
  78. package/_types/utils/uuidV4.d.ts.map +1 -0
  79. package/_types/version.d.ts +1 -1
  80. package/accounts/evm/toEvmServerAccount.ts +33 -15
  81. package/accounts/evm/toEvmSmartAccount.ts +25 -0
  82. package/accounts/evm/types.ts +14 -6
  83. package/actions/evm/signAndWrapTypedDataForSmartAccount.ts +246 -0
  84. package/actions/evm/swap/createSwapQuote.ts +42 -17
  85. package/actions/evm/swap/getSwapPrice.ts +15 -11
  86. package/actions/evm/swap/sendSwapOperation.ts +182 -0
  87. package/actions/evm/swap/sendSwapTransaction.ts +18 -2
  88. package/actions/evm/swap/types.ts +154 -5
  89. package/actions/evm/types.ts +123 -21
  90. package/client/cdp.ts +1 -1
  91. package/client/evm/evm.ts +101 -33
  92. package/client/evm/evm.types.ts +48 -6
  93. package/client/solana/solana.ts +61 -0
  94. package/client/solana/solana.types.ts +15 -2
  95. package/package.json +1 -1
  96. package/utils/export.ts +89 -0
  97. package/utils/uuidV4.ts +23 -0
  98. package/version.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { CreateAccountOptions, GetAccountOptions, GetOrCreateAccountOptions, ListAccountsOptions, ListAccountsResult, RequestFaucetOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, SolanaClientInterface, UpdateSolanaAccountOptions } from "./solana.types.js";
1
+ import { CreateAccountOptions, ExportAccountOptions, GetAccountOptions, GetOrCreateAccountOptions, ListAccountsOptions, ListAccountsResult, RequestFaucetOptions, SignatureResult, SignMessageOptions, SignTransactionOptions, SolanaClientInterface, UpdateSolanaAccountOptions } from "./solana.types.js";
2
2
  import { SolanaAccount } from "../../accounts/solana/types.js";
3
3
  /**
4
4
  * The namespace containing all Solana methods.
@@ -35,6 +35,31 @@ export declare class SolanaClient implements SolanaClientInterface {
35
35
  * ```
36
36
  */
37
37
  createAccount(options?: CreateAccountOptions): Promise<SolanaAccount>;
38
+ /**
39
+ * Exports a CDP Solana account's private key.
40
+ * It is important to store the private key in a secure place after it's exported.
41
+ *
42
+ * @param {ExportAccountOptions} options - Parameters for exporting the Solana account.
43
+ * @param {string} [options.address] - The address of the account.
44
+ * @param {string} [options.name] - The name of the account.
45
+ *
46
+ * @returns A promise that resolves to the exported account's full 64-byte private key as a base58 encoded string.
47
+ *
48
+ * @example **With an address**
49
+ * ```ts
50
+ * const privateKey = await cdp.solana.exportAccount({
51
+ * address: "1234567890123456789012345678901234567890",
52
+ * });
53
+ * ```
54
+ *
55
+ * @example **With a name**
56
+ * ```ts
57
+ * const privateKey = await cdp.solana.exportAccount({
58
+ * name: "MyAccount",
59
+ * });
60
+ * ```
61
+ */
62
+ exportAccount(options: ExportAccountOptions): Promise<string>;
38
63
  /**
39
64
  * Gets a Solana account by its address.
40
65
  *
@@ -1 +1 @@
1
- {"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../client/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EA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UpdateSolanaAccountBody } from "../../openapi-cli
5
5
  */
6
6
  export type SolanaClientInterface = Omit<typeof OpenApiSolanaMethods, "createSolanaAccount" | "getSolanaAccount" | "getSolanaAccountByName" | "updateSolanaAccount" | "listSolanaAccounts" | "requestSolanaFaucet" | "signSolanaMessage" | "signSolanaTransaction" | "updateSolanaAccount" | "exportSolanaAccount" | "exportSolanaAccountByName"> & {
7
7
  createAccount: (options: CreateAccountOptions) => Promise<Account>;
8
+ exportAccount: (options: ExportAccountOptions) => Promise<string>;
8
9
  getAccount: (options: GetAccountOptions) => Promise<Account>;
9
10
  getOrCreateAccount: (options: GetOrCreateAccountOptions) => Promise<Account>;
10
11
  updateAccount: (options: UpdateSolanaAccountOptions) => Promise<Account>;
@@ -31,6 +32,17 @@ export interface CreateAccountOptions {
31
32
  /** The idempotency key. */
32
33
  idempotencyKey?: string;
33
34
  }
35
+ /**
36
+ * Options for exporting a Solana account.
37
+ */
38
+ export interface ExportAccountOptions {
39
+ /** The address of the account. */
40
+ address?: string;
41
+ /** The name of the account. */
42
+ name?: string;
43
+ /** The idempotency key. */
44
+ idempotencyKey?: string;
45
+ }
34
46
  /**
35
47
  * Options for getting a Solana account.
36
48
  */
@@ -1 +1 @@
1
- {"version":3,"file":"solana.types.d.ts","sourceRoot":"","sources":["../../../client/solana/solana.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE9F;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,OAAO,oBAAoB,EACzB,qBAAqB,GACrB,kBAAkB,GAClB,wBAAwB,GACxB,qBAAqB,GACrB,oBAAoB,GACpB,qBAAqB,GACrB,mBAAmB,GACnB,uBAAuB,GACvB,qBAAqB,GACrB,qBAAqB,GACrB,2BAA2B,CAC9B,GAAG;IACF,aAAa,EAAE,CAA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MAAM,CAAC;IAChB,0CAA0C;IAC1C,MAAM,EAAE,uBAAuB,CAAC;IAChC,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,oBAAoB;IACpB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAC;IACtB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
1
+ {"version":3,"file":"solana.types.d.ts","sourceRoot":"","sources":["../../../client/solana/solana.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE9F;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,I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2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Generates a new RSA key pair with 4096-bit private key.
3
+ * - Private key in PKCS1 DER format
4
+ * - Public key in PKIX/SPKI DER format
5
+ *
6
+ * @returns A promise that resolves to the generated key pair, or rejects with an error.
7
+ */
8
+ export declare const generateExportEncryptionKeyPair: () => Promise<{
9
+ publicKey: string;
10
+ privateKey: string;
11
+ }>;
12
+ /**
13
+ * Decrypts a ciphertext using RSA-OAEP-SHA256.
14
+ * - Parses PKCS1 private key
15
+ * - Uses RSA-OAEP-SHA256 for decryption
16
+ * - Returns hex-encoded result
17
+ *
18
+ * @param b64PrivateKey - The base64-encoded private key in PKCS1 DER format.
19
+ * @param b64Cipher - The base64-encoded ciphertext.
20
+ * @returns The decrypted key hex string, or throws an error if decryption fails.
21
+ */
22
+ export declare const decryptWithPrivateKey: (b64PrivateKey: string, b64Cipher: string) => string;
23
+ /**
24
+ * Format a private key to a base58 string for easy import into Solana wallet apps.
25
+ *
26
+ * @param privateKey - The private key as a hex string
27
+ * @returns The formatted private key as a base58 string
28
+ */
29
+ export declare const formatSolanaPrivateKey: (privateKey: string) => string;
30
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../utils/export.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B;eAE7B,MAAM;gBACL,MAAM;EA0BrB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,EAAE,WAAW,MAAM,KAAG,MAsBhF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,YAAY,MAAM,KAAG,MAK3D,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Deterministically generates a UUIDv4 from a given input string.
3
+ * This is necessary when we need to generate downstream idempotency keys for operations that have multiple calls.
4
+ *
5
+ * @param input - The input string to derive from
6
+ * @param salt - Optional salt to append to the input (defaults to "salt")
7
+ * @returns A UUIDv4 formatted string
8
+ */
9
+ export declare function createDeterministicUuidV4(input: string, salt?: string): string;
10
+ //# sourceMappingURL=uuidV4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuidV4.d.ts","sourceRoot":"","sources":["../../utils/uuidV4.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAS,GAAG,MAAM,CAY9E"}
@@ -1,2 +1,2 @@
1
- export declare const version = "1.14.0";
1
+ export declare const version = "1.16.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,11 @@
1
- import { type TransactionSerializable, getTypesForEIP712Domain, serializeTransaction } from "viem";
1
+ import {
2
+ type TransactionSerializable,
3
+ type TypedDataDefinition,
4
+ type TypedData,
5
+ type HashTypedDataParameters,
6
+ getTypesForEIP712Domain,
7
+ serializeTransaction,
8
+ } from "viem";
2
9
 
3
10
  import { FundOptions, fund } from "../../actions/evm/fund/fund.js";
4
11
  import { Quote } from "../../actions/evm/fund/Quote.js";
@@ -31,13 +38,13 @@ import type {
31
38
  TransactionResult,
32
39
  } from "../../actions/evm/sendTransaction.js";
33
40
  import type {
34
- SwapOptions,
35
- SwapResult,
36
- QuoteSwapOptions,
37
- QuoteSwapResult,
41
+ AccountSwapOptions,
42
+ AccountSwapResult,
43
+ AccountQuoteSwapOptions,
44
+ AccountQuoteSwapResult,
38
45
  } from "../../actions/evm/swap/types.js";
39
46
  import type { CdpOpenApiClientType, EvmAccount } from "../../openapi-client/index.js";
40
- import type { Address, EIP712Message, Hash, Hex } from "../../types/misc.js";
47
+ import type { Address, EIP712Domain, Hash, Hex } from "../../types/misc.js";
41
48
 
42
49
  /**
43
50
  * Options for converting a pre-existing EvmAccount to a EvmServerAccount.
@@ -83,13 +90,24 @@ export function toEvmServerAccount(
83
90
  return result.signedTransaction as Hex;
84
91
  },
85
92
 
86
- async signTypedData(message: EIP712Message) {
87
- if (!message.types.EIP712Domain) {
88
- message.types.EIP712Domain = getTypesForEIP712Domain({
89
- domain: message.domain,
90
- });
91
- }
92
- const result = await apiClient.signEvmTypedData(options.account.address, message);
93
+ async signTypedData<
94
+ const typedData extends TypedData | Record<string, unknown>,
95
+ primaryType extends keyof typedData | "EIP712Domain" = keyof typedData,
96
+ >(parameters: TypedDataDefinition<typedData, primaryType>) {
97
+ const { domain = {}, message, primaryType } = parameters as HashTypedDataParameters;
98
+ const types = {
99
+ EIP712Domain: getTypesForEIP712Domain({ domain }),
100
+ ...parameters.types,
101
+ };
102
+
103
+ const openApiMessage = {
104
+ domain: domain as EIP712Domain,
105
+ types,
106
+ primaryType,
107
+ message,
108
+ };
109
+
110
+ const result = await apiClient.signEvmTypedData(options.account.address, openApiMessage);
93
111
  return result.signature as Hex;
94
112
  },
95
113
  async transfer(transferArgs): Promise<TransactionResult> {
@@ -134,13 +152,13 @@ export function toEvmServerAccount(
134
152
  ): Promise<WaitForFundOperationResult> {
135
153
  return waitForFundOperationReceipt(apiClient, options);
136
154
  },
137
- async quoteSwap(options: QuoteSwapOptions): Promise<QuoteSwapResult> {
155
+ async quoteSwap(options: AccountQuoteSwapOptions): Promise<AccountQuoteSwapResult> {
138
156
  return createSwapQuote(apiClient, {
139
157
  ...options,
140
158
  taker: this.address,
141
159
  });
142
160
  },
143
- async swap(options: SwapOptions): Promise<SwapResult> {
161
+ async swap(options: AccountSwapOptions): Promise<AccountSwapResult> {
144
162
  return sendSwapTransaction(apiClient, {
145
163
  ...options,
146
164
  address: this.address,
@@ -23,6 +23,8 @@ import {
23
23
  type SendUserOperationReturnType,
24
24
  sendUserOperation,
25
25
  } from "../../actions/evm/sendUserOperation.js";
26
+ import { createSwapQuote } from "../../actions/evm/swap/createSwapQuote.js";
27
+ import { sendSwapOperation } from "../../actions/evm/swap/sendSwapOperation.js";
26
28
  import { smartAccountTransferStrategy } from "../../actions/evm/transfer/smartAccountTransferStrategy.js";
27
29
  import { transfer } from "../../actions/evm/transfer/transfer.js";
28
30
  import {
@@ -33,6 +35,12 @@ import {
33
35
  import { GetUserOperationOptions, UserOperation } from "../../client/evm/evm.types.js";
34
36
 
35
37
  import type { EvmAccount, EvmSmartAccount } from "./types.js";
38
+ import type {
39
+ SmartAccountQuoteSwapOptions,
40
+ SmartAccountQuoteSwapResult,
41
+ SmartAccountSwapOptions,
42
+ SmartAccountSwapResult,
43
+ } from "../../actions/evm/swap/types.js";
36
44
  import type {
37
45
  CdpOpenApiClientType,
38
46
  EvmSmartAccount as EvmSmartAccountModel,
@@ -128,6 +136,23 @@ export function toEvmSmartAccount(
128
136
  ): Promise<WaitForFundOperationResult> {
129
137
  return waitForFundOperationReceipt(apiClient, options);
130
138
  },
139
+ async quoteSwap(options: SmartAccountQuoteSwapOptions): Promise<SmartAccountQuoteSwapResult> {
140
+ return createSwapQuote(apiClient, {
141
+ ...options,
142
+ taker: this.address, // Always use smart account's address as taker
143
+ signerAddress: this.owners[0].address, // Always use owner's address as signer
144
+ smartAccount: account, // Pass smart account for execute method support
145
+ });
146
+ },
147
+ async swap(options: SmartAccountSwapOptions): Promise<SmartAccountSwapResult> {
148
+ return sendSwapOperation(apiClient, {
149
+ ...options,
150
+ smartAccount: account,
151
+ taker: this.address, // Always use smart account's address as taker
152
+ signerAddress: this.owners[0].address, // Always use owner's address as signer
153
+ });
154
+ },
155
+
131
156
  name: options.smartAccount.name,
132
157
  type: "evm-smart",
133
158
  };
@@ -1,9 +1,12 @@
1
- import { SignableMessage, TransactionSerializable } from "viem";
2
-
3
- import { Prettify } from "../../types/utils.js";
4
-
5
1
  import type { AccountActions, SmartAccountActions } from "../../actions/evm/types.js";
6
- import type { Address, EIP712Message, Hash, Hex } from "../../types/misc.js";
2
+ import type { Address, Hash, Hex } from "../../types/misc.js";
3
+ import type { Prettify } from "../../types/utils.js";
4
+ import type {
5
+ SignableMessage,
6
+ TransactionSerializable,
7
+ TypedData,
8
+ TypedDataDefinition,
9
+ } from "viem";
7
10
 
8
11
  /**
9
12
  * Base type for any Ethereum account with signing capabilities.
@@ -19,7 +22,12 @@ export type EvmAccount = {
19
22
  /** Signs a transaction and returns the signed transaction as a hex string. */
20
23
  signTransaction: (transaction: TransactionSerializable) => Promise<Hex>;
21
24
  /** Signs a typed data and returns the signature as a hex string. */
22
- signTypedData: (message: EIP712Message) => Promise<Hex>;
25
+ signTypedData: <
26
+ const typedData extends TypedData | Record<string, unknown>,
27
+ primaryType extends keyof typedData | "EIP712Domain" = keyof typedData,
28
+ >(
29
+ parameters: TypedDataDefinition<typedData, primaryType>,
30
+ ) => Promise<Hex>;
23
31
  /** A list of Policy ID's that apply to the account. */
24
32
  policies?: string[];
25
33
  };
@@ -0,0 +1,246 @@
1
+ import { encodeAbiParameters, encodePacked, hashTypedData, sliceHex } from "viem";
2
+
3
+ import type { EvmSmartAccount } from "../../accounts/evm/types.js";
4
+ import type {
5
+ CdpOpenApiClientType,
6
+ EIP712Message as OpenApiEIP712Message,
7
+ } from "../../openapi-client/index.js";
8
+ import type { EIP712Message, Hex } from "../../types/misc.js";
9
+
10
+ /**
11
+ * Options for signing and wrapping EIP-712 typed data with a smart account.
12
+ */
13
+ export interface SignAndWrapTypedDataForSmartAccountOptions {
14
+ /** The smart account to sign with. */
15
+ smartAccount: EvmSmartAccount;
16
+ /** The chain ID for the signature (used for replay protection). */
17
+ chainId: bigint;
18
+ /** The EIP-712 typed data message to sign. */
19
+ typedData: EIP712Message;
20
+ /** The index of the owner to sign with (defaults to 0). */
21
+ ownerIndex?: bigint;
22
+ /** Optional idempotency key for the signing request. */
23
+ idempotencyKey?: string;
24
+ }
25
+
26
+ /**
27
+ * Result of signing and wrapping typed data for a smart account.
28
+ */
29
+ export interface SignAndWrapTypedDataForSmartAccountResult {
30
+ /** The signature ready for smart contract use. */
31
+ signature: Hex;
32
+ }
33
+
34
+ /**
35
+ * Signs and wraps an EIP-712 message for a smart account using the required Coinbase Smart Wallet signature format.
36
+ *
37
+ * **Important: Coinbase Smart Wallet Contract Requirements**
38
+ *
39
+ * Due to the Coinbase Smart Wallet contract implementation (ERC-1271), CDP Smart Wallets have
40
+ * specific requirements for EIP-712 message signing:
41
+ *
42
+ * 1. **Replay-Safe Hashing**: All typed messages must be wrapped in a replay-safe hash that
43
+ * includes the chain ID and smart account address. This prevents the same signature from
44
+ * being valid across different chains or accounts.
45
+ *
46
+ * 2. **Signature Wrapping**: The resulting signature must be wrapped in a `SignatureWrapper`
47
+ * struct that identifies which owner signed and contains the signature data in the format
48
+ * expected by the smart contract's `isValidSignature()` method.
49
+ *
50
+ * This function handles both requirements automatically, making it safe and convenient for
51
+ * developers to sign EIP-712 messages with CDP Smart Wallets.
52
+ *
53
+ * @param {CdpOpenApiClientType} client - The CDP API client
54
+ * @param {SignAndWrapTypedDataForSmartAccountOptions} options - Parameters for signing and wrapping the EIP-712 message.
55
+ * @returns A promise that resolves to the signature that can be used with smart contracts.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * const result = await signAndWrapTypedDataForSmartAccount(client, {
60
+ * smartAccount: smartAccount,
61
+ * chainId: 1n,
62
+ * typedData: {
63
+ * domain: {
64
+ * name: "Permit2",
65
+ * chainId: 1,
66
+ * verifyingContract: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
67
+ * },
68
+ * types: {
69
+ * EIP712Domain: [
70
+ * { name: "name", type: "string" },
71
+ * { name: "chainId", type: "uint256" },
72
+ * { name: "verifyingContract", type: "address" },
73
+ * ],
74
+ * PermitTransferFrom: [
75
+ * { name: "permitted", type: "TokenPermissions" },
76
+ * { name: "spender", type: "address" },
77
+ * { name: "nonce", type: "uint256" },
78
+ * { name: "deadline", type: "uint256" },
79
+ * ],
80
+ * TokenPermissions: [
81
+ * { name: "token", type: "address" },
82
+ * { name: "amount", type: "uint256" },
83
+ * ],
84
+ * },
85
+ * primaryType: "PermitTransferFrom",
86
+ * message: {
87
+ * permitted: {
88
+ * token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
89
+ * amount: "1000000",
90
+ * },
91
+ * spender: "0xFfFfFfFFfFFfFFfFFfFFFFFffFFFffffFfFFFfFf",
92
+ * nonce: "0",
93
+ * deadline: "1717123200",
94
+ * },
95
+ * },
96
+ * });
97
+ *
98
+ * // Use result.signature for smart contract calls
99
+ * console.log(`Signature: ${result.signature}`);
100
+ * ```
101
+ */
102
+ export async function signAndWrapTypedDataForSmartAccount(
103
+ client: CdpOpenApiClientType,
104
+ options: SignAndWrapTypedDataForSmartAccountOptions,
105
+ ): Promise<SignAndWrapTypedDataForSmartAccountResult> {
106
+ const { smartAccount, chainId, typedData, ownerIndex = 0n } = options;
107
+
108
+ // Create the replay-safe typed data
109
+ const replaySafeTypedData = createReplaySafeTypedData({
110
+ typedData,
111
+ chainId,
112
+ smartAccountAddress: smartAccount.address as Hex,
113
+ });
114
+
115
+ // Sign the replay-safe typed data with the smart account owner
116
+ const owner = smartAccount.owners[Number(ownerIndex)];
117
+ const signature = await client.signEvmTypedData(
118
+ owner.address,
119
+ replaySafeTypedData,
120
+ options.idempotencyKey,
121
+ );
122
+
123
+ // Wrap the signature in the format expected by the smart contract
124
+ const wrappedSignature = createSmartAccountSignatureWrapper({
125
+ signatureHex: signature.signature as Hex,
126
+ ownerIndex,
127
+ });
128
+
129
+ return {
130
+ signature: wrappedSignature as Hex,
131
+ };
132
+ }
133
+
134
+ /**
135
+ * Creates a replay-safe EIP-712 typed data structure by wrapping the original typed data with
136
+ * chain ID and smart account address.
137
+ *
138
+ * **Coinbase Smart Wallet Requirement**: Due to the Coinbase Smart Wallet contract's ERC-1271
139
+ * implementation, all EIP-712 messages must be wrapped in a replay-safe hash before signing.
140
+ * This prevents signature replay attacks across different chains or smart account addresses.
141
+ *
142
+ * The smart contract's `isValidSignature()` method expects signatures to be validated against
143
+ * this replay-safe hash, not the original message hash.
144
+ *
145
+ * @param params - The replay-safe hash parameters
146
+ * @param params.typedData - The original EIP-712 typed data to make replay-safe
147
+ * @param params.chainId - The chain ID for replay protection
148
+ * @param params.smartAccountAddress - The smart account address for additional context
149
+ * @returns The EIP-712 typed data structure for the replay-safe hash
150
+ */
151
+ export function createReplaySafeTypedData({
152
+ typedData,
153
+ chainId,
154
+ smartAccountAddress,
155
+ }: {
156
+ typedData: EIP712Message;
157
+ chainId: bigint;
158
+ smartAccountAddress: Hex;
159
+ }): OpenApiEIP712Message {
160
+ // First hash the original typed data
161
+ const originalHash = hashTypedData(typedData);
162
+
163
+ // Create and return the replay-safe typed data structure
164
+ return {
165
+ domain: {
166
+ name: "Coinbase Smart Wallet",
167
+ version: "1",
168
+ chainId: Number(chainId),
169
+ verifyingContract: smartAccountAddress,
170
+ },
171
+ types: {
172
+ EIP712Domain: [
173
+ { name: "name", type: "string" },
174
+ { name: "version", type: "string" },
175
+ { name: "chainId", type: "uint256" },
176
+ { name: "verifyingContract", type: "address" },
177
+ ],
178
+ CoinbaseSmartWalletMessage: [{ name: "hash", type: "bytes32" }],
179
+ },
180
+ primaryType: "CoinbaseSmartWalletMessage" as const,
181
+ message: {
182
+ hash: originalHash,
183
+ },
184
+ };
185
+ }
186
+
187
+ /**
188
+ * Builds a signature wrapper for Coinbase Smart Wallets by decomposing a hex signature
189
+ * into r, s, v components and encoding them in the format expected by the smart contract.
190
+ *
191
+ * All signatures on Coinbase Smart Wallets must be wrapped in this format to identify
192
+ * which owner signed and provide the signature data.
193
+ *
194
+ * @param params - The signature parameters
195
+ * @param params.signatureHex - The hex signature to wrap (65 bytes: r + s + v)
196
+ * @param params.ownerIndex - The index of the owner that signed (from MultiOwnable.ownerAtIndex)
197
+ * @returns The encoded signature wrapper in the format expected by the smart contract
198
+ */
199
+ export function createSmartAccountSignatureWrapper({
200
+ signatureHex,
201
+ ownerIndex,
202
+ }: {
203
+ signatureHex: Hex;
204
+ ownerIndex: bigint;
205
+ }): Hex {
206
+ // Decompose 65-byte hex signature into r (32 bytes), s (32 bytes), v (1 byte)
207
+ const r = sliceHex(signatureHex, 0, 32);
208
+ const s = sliceHex(signatureHex, 32, 64);
209
+ const v = Number(`0x${signatureHex.slice(130, 132)}`); // 130 = 2 + 64 + 64
210
+
211
+ const signatureData = encodePacked(["bytes32", "bytes32", "uint8"], [r, s, v]);
212
+
213
+ return encodeAbiParameters(
214
+ [SignatureWrapperStruct],
215
+ [
216
+ {
217
+ ownerIndex: Number(ownerIndex),
218
+ signatureData,
219
+ },
220
+ ],
221
+ ) as Hex;
222
+ }
223
+
224
+ /**
225
+ * The ABI structure for the SignatureWrapper struct expected by Coinbase Smart Wallets.
226
+ * This matches the struct defined in the smart contract:
227
+ *
228
+ * struct SignatureWrapper {
229
+ * uint256 ownerIndex;
230
+ * bytes signatureData;
231
+ * }
232
+ */
233
+ const SignatureWrapperStruct = {
234
+ components: [
235
+ {
236
+ name: "ownerIndex",
237
+ type: "uint8",
238
+ },
239
+ {
240
+ name: "signatureData",
241
+ type: "bytes",
242
+ },
243
+ ],
244
+ name: "SignatureWrapper",
245
+ type: "tuple",
246
+ } as const;
@@ -1,3 +1,4 @@
1
+ import { sendSwapOperation } from "./sendSwapOperation.js";
1
2
  import { sendSwapTransaction } from "./sendSwapTransaction.js";
2
3
  import {
3
4
  CreateSwapQuoteOptions,
@@ -10,9 +11,12 @@ import {
10
11
  CdpOpenApiClientType,
11
12
  CreateSwapQuoteResponse,
12
13
  type SendEvmTransactionBodyNetwork,
14
+ type EvmUserOperationNetwork,
13
15
  } from "../../../openapi-client/index.js";
14
16
  import { Address, Hex } from "../../../types/misc.js";
15
17
 
18
+ import type { EvmSmartAccount } from "../../../accounts/evm/types.js";
19
+
16
20
  /**
17
21
  * Creates a quote for a swap between two tokens on an EVM network.
18
22
  *
@@ -45,16 +49,19 @@ export async function createSwapQuote(
45
49
  const taker = options.taker as Address;
46
50
 
47
51
  // Call the createEvmSwapQuote function directly with the client's configured API
48
- const response = await client.createEvmSwapQuote({
49
- network: options.network,
50
- toToken: options.toToken,
51
- fromToken: options.fromToken,
52
- fromAmount: options.fromAmount.toString(),
53
- taker: taker,
54
- signerAddress: options.signerAddress,
55
- gasPrice: options.gasPrice?.toString(),
56
- slippageBps: options.slippageBps,
57
- });
52
+ const response = await client.createEvmSwapQuote(
53
+ {
54
+ network: options.network,
55
+ toToken: options.toToken,
56
+ fromToken: options.fromToken,
57
+ fromAmount: options.fromAmount.toString(),
58
+ taker: taker,
59
+ signerAddress: options.signerAddress,
60
+ gasPrice: options.gasPrice?.toString(),
61
+ slippageBps: options.slippageBps,
62
+ },
63
+ options.idempotencyKey,
64
+ );
58
65
 
59
66
  // Check if liquidity is unavailable
60
67
  if (!response.liquidityAvailable) {
@@ -134,13 +141,31 @@ export async function createSwapQuote(
134
141
  execute: async (
135
142
  executeOptions: ExecuteSwapQuoteOptions = {},
136
143
  ): Promise<ExecuteSwapQuoteResult> => {
137
- const { transactionHash } = await sendSwapTransaction(client, {
138
- address: options.signerAddress || taker, // Use signerAddress for smart accounts, taker for EOAs
139
- network: result.network as SendEvmTransactionBodyNetwork,
140
- swapQuote: result,
141
- idempotencyKey: executeOptions.idempotencyKey,
142
- });
143
- return { transactionHash };
144
+ if (options.smartAccount) {
145
+ // Smart account execution - use sendSwapOperation
146
+ const userOpResult = await sendSwapOperation(client, {
147
+ smartAccount: options.smartAccount as EvmSmartAccount,
148
+ network: result.network as EvmUserOperationNetwork,
149
+ swapQuote: result,
150
+ idempotencyKey: executeOptions.idempotencyKey,
151
+ });
152
+
153
+ return {
154
+ userOpHash: userOpResult.userOpHash,
155
+ smartAccountAddress: userOpResult.smartAccountAddress,
156
+ status: userOpResult.status,
157
+ };
158
+ } else {
159
+ // EOA execution - use sendSwapTransaction
160
+ const { transactionHash } = await sendSwapTransaction(client, {
161
+ address: taker,
162
+ network: result.network as SendEvmTransactionBodyNetwork,
163
+ swapQuote: result,
164
+ idempotencyKey: executeOptions.idempotencyKey,
165
+ });
166
+
167
+ return { transactionHash };
168
+ }
144
169
  },
145
170
  };
146
171