@coinbase/cdp-sdk 1.27.0 → 1.29.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 (140) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/_cjs/accounts/evm/toEvmServerAccount.js +1 -1
  3. package/_cjs/accounts/evm/toEvmServerAccount.js.map +1 -1
  4. package/_cjs/accounts/evm/toEvmSmartAccount.js +1 -1
  5. package/_cjs/accounts/evm/toEvmSmartAccount.js.map +1 -1
  6. package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js +11 -6
  7. package/_cjs/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
  8. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js +1 -1
  9. package/_cjs/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  10. package/_cjs/accounts/solana/toSolanaAccount.js +30 -0
  11. package/_cjs/accounts/solana/toSolanaAccount.js.map +1 -1
  12. package/_cjs/actions/Quote.js +106 -0
  13. package/_cjs/actions/Quote.js.map +1 -0
  14. package/_cjs/actions/evm/fund/fund.js +5 -5
  15. package/_cjs/actions/evm/fund/fund.js.map +1 -1
  16. package/_cjs/actions/evm/fund/quoteFund.js +7 -7
  17. package/_cjs/actions/evm/fund/quoteFund.js.map +1 -1
  18. package/_cjs/actions/evm/transfer/accountTransferStrategy.js +1 -0
  19. package/_cjs/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  20. package/_cjs/actions/solana/fund/fund.js +50 -0
  21. package/_cjs/actions/solana/fund/fund.js.map +1 -0
  22. package/_cjs/actions/solana/fund/quoteFund.js +47 -0
  23. package/_cjs/actions/solana/fund/quoteFund.js.map +1 -0
  24. package/_cjs/actions/solana/transfer.js +25 -38
  25. package/_cjs/actions/solana/transfer.js.map +1 -1
  26. package/_cjs/actions/solana/utils.js +4 -14
  27. package/_cjs/actions/solana/utils.js.map +1 -1
  28. package/{_esm/actions/evm/fund → _cjs/actions}/types.js.map +1 -1
  29. package/_cjs/actions/{evm/fund/waitForFundOperationReceipt.js → waitForFundOperationReceipt.js} +2 -2
  30. package/_cjs/actions/waitForFundOperationReceipt.js.map +1 -0
  31. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +15 -6
  32. package/_cjs/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  33. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +4 -3
  34. package/_cjs/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  35. package/_cjs/policies/schema.js +6 -6
  36. package/_cjs/version.js +1 -1
  37. package/_esm/accounts/evm/toEvmServerAccount.js +1 -1
  38. package/_esm/accounts/evm/toEvmServerAccount.js.map +1 -1
  39. package/_esm/accounts/evm/toEvmSmartAccount.js +1 -1
  40. package/_esm/accounts/evm/toEvmSmartAccount.js.map +1 -1
  41. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js +11 -6
  42. package/_esm/accounts/evm/toNetworkScopedEvmServerAccount.js.map +1 -1
  43. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js +1 -1
  44. package/_esm/accounts/evm/toNetworkScopedEvmSmartAccount.js.map +1 -1
  45. package/_esm/accounts/solana/toSolanaAccount.js +30 -0
  46. package/_esm/accounts/solana/toSolanaAccount.js.map +1 -1
  47. package/_esm/actions/Quote.js +101 -0
  48. package/_esm/actions/Quote.js.map +1 -0
  49. package/_esm/actions/evm/fund/fund.js +5 -5
  50. package/_esm/actions/evm/fund/fund.js.map +1 -1
  51. package/_esm/actions/evm/fund/quoteFund.js +7 -7
  52. package/_esm/actions/evm/fund/quoteFund.js.map +1 -1
  53. package/_esm/actions/evm/transfer/accountTransferStrategy.js +1 -0
  54. package/_esm/actions/evm/transfer/accountTransferStrategy.js.map +1 -1
  55. package/_esm/actions/solana/fund/fund.js +47 -0
  56. package/_esm/actions/solana/fund/fund.js.map +1 -0
  57. package/_esm/actions/solana/fund/quoteFund.js +44 -0
  58. package/_esm/actions/solana/fund/quoteFund.js.map +1 -0
  59. package/_esm/actions/solana/transfer.js +26 -39
  60. package/_esm/actions/solana/transfer.js.map +1 -1
  61. package/_esm/actions/solana/utils.js +5 -15
  62. package/_esm/actions/solana/utils.js.map +1 -1
  63. package/{_cjs/actions/evm/fund → _esm/actions}/types.js.map +1 -1
  64. package/_esm/actions/{evm/fund/waitForFundOperationReceipt.js → waitForFundOperationReceipt.js} +2 -2
  65. package/_esm/actions/waitForFundOperationReceipt.js.map +1 -0
  66. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js +14 -5
  67. package/_esm/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.js.map +1 -1
  68. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js +4 -3
  69. package/_esm/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.js.map +1 -1
  70. package/_esm/policies/schema.js +6 -6
  71. package/_esm/version.js +1 -1
  72. package/_types/accounts/evm/toNetworkScopedEvmServerAccount.d.ts.map +1 -1
  73. package/_types/accounts/evm/types.d.ts +9 -9
  74. package/_types/accounts/evm/types.d.ts.map +1 -1
  75. package/_types/accounts/solana/toSolanaAccount.d.ts.map +1 -1
  76. package/_types/actions/Quote.d.ts +97 -0
  77. package/_types/actions/Quote.d.ts.map +1 -0
  78. package/_types/actions/evm/fund/fund.d.ts +3 -7
  79. package/_types/actions/evm/fund/fund.d.ts.map +1 -1
  80. package/_types/actions/evm/fund/quoteFund.d.ts +4 -7
  81. package/_types/actions/evm/fund/quoteFund.d.ts.map +1 -1
  82. package/_types/actions/evm/transfer/accountTransferStrategy.d.ts.map +1 -1
  83. package/_types/actions/evm/types.d.ts +7 -7
  84. package/_types/actions/evm/types.d.ts.map +1 -1
  85. package/_types/actions/solana/fund/fund.d.ts +19 -0
  86. package/_types/actions/solana/fund/fund.d.ts.map +1 -0
  87. package/_types/actions/solana/fund/quoteFund.d.ts +20 -0
  88. package/_types/actions/solana/fund/quoteFund.d.ts.map +1 -0
  89. package/_types/actions/solana/transfer.d.ts.map +1 -1
  90. package/_types/actions/solana/types.d.ts +61 -0
  91. package/_types/actions/solana/types.d.ts.map +1 -1
  92. package/_types/actions/solana/utils.d.ts +2 -2
  93. package/_types/actions/solana/utils.d.ts.map +1 -1
  94. package/_types/actions/types.d.ts +37 -0
  95. package/_types/actions/types.d.ts.map +1 -0
  96. package/_types/actions/{evm/fund/waitForFundOperationReceipt.d.ts → waitForFundOperationReceipt.d.ts} +2 -2
  97. package/_types/actions/waitForFundOperationReceipt.d.ts.map +1 -0
  98. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts +26 -22
  99. package/_types/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.d.ts.map +1 -1
  100. package/_types/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.d.ts.map +1 -1
  101. package/_types/policies/schema.d.ts +34 -34
  102. package/_types/version.d.ts +1 -1
  103. package/accounts/evm/toEvmServerAccount.ts +11 -11
  104. package/accounts/evm/toEvmSmartAccount.ts +11 -11
  105. package/accounts/evm/toNetworkScopedEvmServerAccount.ts +17 -11
  106. package/accounts/evm/toNetworkScopedEvmSmartAccount.ts +6 -6
  107. package/accounts/evm/types.ts +16 -12
  108. package/accounts/solana/toSolanaAccount.ts +41 -0
  109. package/actions/Quote.ts +154 -0
  110. package/actions/evm/fund/fund.ts +10 -14
  111. package/actions/evm/fund/quoteFund.ts +13 -16
  112. package/actions/evm/transfer/accountTransferStrategy.ts +2 -0
  113. package/actions/evm/types.ts +7 -7
  114. package/actions/solana/fund/fund.ts +71 -0
  115. package/actions/solana/fund/quoteFund.ts +77 -0
  116. package/actions/solana/transfer.ts +33 -52
  117. package/actions/solana/types.ts +69 -0
  118. package/actions/solana/utils.ts +5 -13
  119. package/actions/types.ts +39 -0
  120. package/actions/{evm/fund/waitForFundOperationReceipt.ts → waitForFundOperationReceipt.ts} +2 -2
  121. package/openapi-client/generated/coinbaseDeveloperPlatformAPIs.schemas.ts +30 -30
  122. package/openapi-client/generated/evm-smart-accounts/evm-smart-accounts.msw.ts +4 -3
  123. package/package.json +1 -1
  124. package/policies/schema.ts +6 -6
  125. package/version.ts +1 -1
  126. package/_cjs/actions/evm/fund/Quote.js +0 -63
  127. package/_cjs/actions/evm/fund/Quote.js.map +0 -1
  128. package/_cjs/actions/evm/fund/waitForFundOperationReceipt.js.map +0 -1
  129. package/_esm/actions/evm/fund/Quote.js +0 -59
  130. package/_esm/actions/evm/fund/Quote.js.map +0 -1
  131. package/_esm/actions/evm/fund/waitForFundOperationReceipt.js.map +0 -1
  132. package/_types/actions/evm/fund/Quote.d.ts +0 -51
  133. package/_types/actions/evm/fund/Quote.d.ts.map +0 -1
  134. package/_types/actions/evm/fund/types.d.ts +0 -16
  135. package/_types/actions/evm/fund/types.d.ts.map +0 -1
  136. package/_types/actions/evm/fund/waitForFundOperationReceipt.d.ts.map +0 -1
  137. package/actions/evm/fund/Quote.ts +0 -83
  138. package/actions/evm/fund/types.ts +0 -16
  139. /package/_cjs/actions/{evm/fund/types.js → types.js} +0 -0
  140. /package/_esm/actions/{evm/fund/types.js → types.js} +0 -0
@@ -7,14 +7,13 @@ import {
7
7
  } from "@solana/spl-token";
8
8
  import {
9
9
  Connection,
10
- MessageV0,
11
10
  PublicKey,
12
11
  SystemProgram,
13
- TransactionInstruction,
14
- TransactionMessage,
15
- VersionedTransaction,
12
+ SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
13
+ Transaction,
16
14
  } from "@solana/web3.js";
17
15
 
16
+ import { sendTransaction } from "./sendTransaction.js";
18
17
  import {
19
18
  getConnectedNetwork,
20
19
  getOrCreateConnection,
@@ -61,11 +60,11 @@ export async function transfer(
61
60
  options: TransferOptions,
62
61
  ): Promise<SignatureResult> {
63
62
  const connection = getOrCreateConnection({ networkOrConnection: options.network });
63
+ const connectedNetwork = await getConnectedNetwork(connection);
64
64
 
65
65
  const tx =
66
66
  options.token === "sol"
67
67
  ? await getNativeTransfer({
68
- connection,
69
68
  from: options.from,
70
69
  to: options.to,
71
70
  amount: options.amount,
@@ -75,41 +74,29 @@ export async function transfer(
75
74
  from: options.from,
76
75
  to: options.to,
77
76
  mintAddress:
78
- options.token === "usdc"
79
- ? getUsdcMintAddress(await getConnectedNetwork(connection))
80
- : options.token,
77
+ options.token === "usdc" ? getUsdcMintAddress(connectedNetwork) : options.token,
81
78
  amount: options.amount,
82
79
  });
83
80
 
84
- const serializedTx = Buffer.from(tx.serialize()).toString("base64");
81
+ const serializedTx = Buffer.from(tx.serialize({ requireAllSignatures: false })).toString(
82
+ "base64",
83
+ );
85
84
 
86
- const signedTxResponse = await apiClient.signSolanaTransaction(options.from, {
85
+ const signature = await sendTransaction(apiClient, {
86
+ network: connectedNetwork === "mainnet" ? "solana" : "solana-devnet",
87
87
  transaction: serializedTx,
88
88
  });
89
89
 
90
- const decodedSignedTx = Buffer.from(signedTxResponse.signedTransaction, "base64");
91
-
92
- const signature = await connection.sendRawTransaction(decodedSignedTx, {
93
- skipPreflight: false,
94
- maxRetries: 3,
95
- });
96
-
97
- return { signature };
90
+ return signature;
98
91
  }
99
92
 
100
- type GetNativeTransferOptions = Omit<TransferOptions, "token" | "network"> & {
101
- /**
102
- * The connection to the Solana network
103
- */
104
- connection: Connection;
105
- };
93
+ type GetNativeTransferOptions = Omit<TransferOptions, "token" | "network">;
106
94
 
107
95
  /**
108
- * Gets the instructions for a native SOL transfer
96
+ * Gets the transaction for a native SOL transfer
109
97
  *
110
98
  * @param options - The options for the native SOL transfer
111
99
  *
112
- * @param options.connection - The Solana connection
113
100
  * @param options.from - The source address
114
101
  * @param options.to - The destination address
115
102
  * @param options.amount - The amount to transfer
@@ -117,39 +104,37 @@ type GetNativeTransferOptions = Omit<TransferOptions, "token" | "network"> & {
117
104
  * @returns The native SOL transfer transaction
118
105
  */
119
106
  async function getNativeTransfer({
120
- connection,
121
107
  from,
122
108
  to,
123
109
  amount,
124
- }: GetNativeTransferOptions): Promise<VersionedTransaction> {
125
- const { blockhash } = await connection.getLatestBlockhash();
126
-
127
- const instructions = [
110
+ }: GetNativeTransferOptions): Promise<Transaction> {
111
+ const transaction = new Transaction();
112
+ transaction.add(
128
113
  SystemProgram.transfer({
129
114
  fromPubkey: new PublicKey(from),
130
115
  toPubkey: new PublicKey(to),
131
116
  lamports: amount,
132
117
  }),
133
- ];
134
-
135
- const messageV0 = new TransactionMessage({
136
- payerKey: new PublicKey(from),
137
- recentBlockhash: blockhash,
138
- instructions,
139
- }).compileToV0Message();
118
+ );
119
+ transaction.recentBlockhash = SYSVAR_RECENT_BLOCKHASHES_PUBKEY.toBase58();
120
+ transaction.feePayer = new PublicKey(from);
140
121
 
141
- return new VersionedTransaction(messageV0);
122
+ return transaction;
142
123
  }
143
124
 
144
- type GetSplTransferOptions = GetNativeTransferOptions & {
125
+ type GetSplTransferOptions = Omit<TransferOptions, "token" | "network"> & {
145
126
  /**
146
127
  * The mint address of the token
147
128
  */
148
129
  mintAddress: string;
130
+ /**
131
+ * The connection to the Solana network.
132
+ */
133
+ connection: Connection;
149
134
  };
150
135
 
151
136
  /**
152
- * Gets the instructions for a SPL token transfer
137
+ * Gets the transaction for a SPL token transfer
153
138
  *
154
139
  * @param options - The options for the SPL token transfer
155
140
  *
@@ -167,7 +152,7 @@ async function getSplTransfer({
167
152
  to,
168
153
  mintAddress,
169
154
  amount,
170
- }: GetSplTransferOptions): Promise<VersionedTransaction> {
155
+ }: GetSplTransferOptions): Promise<Transaction> {
171
156
  const fromPubkey = new PublicKey(from);
172
157
  const toPubkey = new PublicKey(to);
173
158
  const mintPubkey = new PublicKey(mintAddress);
@@ -182,7 +167,7 @@ async function getSplTransfer({
182
167
  const sourceAta = await getAssociatedTokenAddress(mintPubkey, fromPubkey);
183
168
  const destinationAta = await getAssociatedTokenAddress(mintPubkey, toPubkey);
184
169
 
185
- const instructions: TransactionInstruction[] = [];
170
+ const transaction = new Transaction();
186
171
 
187
172
  const sourceAccount = await getAccount(connection, sourceAta);
188
173
  if (sourceAccount.amount < amount) {
@@ -193,12 +178,12 @@ async function getSplTransfer({
193
178
  try {
194
179
  await getAccount(connection, destinationAta);
195
180
  } catch {
196
- instructions.push(
181
+ transaction.add(
197
182
  createAssociatedTokenAccountInstruction(fromPubkey, destinationAta, toPubkey, mintPubkey),
198
183
  );
199
184
  }
200
185
 
201
- instructions.push(
186
+ transaction.add(
202
187
  createTransferCheckedInstruction(
203
188
  sourceAta,
204
189
  mintPubkey,
@@ -208,12 +193,8 @@ async function getSplTransfer({
208
193
  mintInfo.decimals,
209
194
  ),
210
195
  );
196
+ transaction.recentBlockhash = SYSVAR_RECENT_BLOCKHASHES_PUBKEY.toBase58();
197
+ transaction.feePayer = new PublicKey(from);
211
198
 
212
- return new VersionedTransaction(
213
- MessageV0.compile({
214
- payerKey: fromPubkey,
215
- instructions: instructions,
216
- recentBlockhash: (await connection.getLatestBlockhash()).blockhash,
217
- }),
218
- );
199
+ return transaction;
219
200
  }
@@ -5,6 +5,14 @@ import {
5
5
  SignMessageOptions,
6
6
  SignTransactionOptions,
7
7
  } from "../../client/solana/solana.types.js";
8
+ import { SolanaQuote } from "../Quote.js";
9
+ import { FundOperationResult } from "../types.js";
10
+ import {
11
+ WaitForFundOperationOptions,
12
+ WaitForFundOperationResult,
13
+ } from "../waitForFundOperationReceipt.js";
14
+ import { SolanaFundOptions } from "./fund/fund.js";
15
+ import { SolanaQuoteFundOptions } from "./fund/quoteFund.js";
8
16
 
9
17
  export type AccountActions = {
10
18
  /**
@@ -112,4 +120,65 @@ export type AccountActions = {
112
120
  * ```
113
121
  */
114
122
  transfer: (options: Omit<TransferOptions, "from">) => Promise<SignatureResult>;
123
+
124
+ /**
125
+ * Gets a quote to fund a Solana account.
126
+ *
127
+ * @param options - The options for the quote fund.
128
+ * @param options.token - The token to fund the account with.
129
+ * @param options.amount - The amount of the token to fund represented as an atomic unit.
130
+ * It's common to use `parseUnits` utils from viem to convert to atomic units.
131
+ * Otherwise, you can pass atomic units directly.
132
+ *
133
+ * @returns A promise that resolves to a Quote object containing details about the funding operation.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * const quote = await account.quoteFund({
138
+ * token: "usdc",
139
+ * amount: 1000000n,
140
+ * });
141
+ * ```
142
+ */
143
+ quoteFund: (options: Omit<SolanaQuoteFundOptions, "address">) => Promise<SolanaQuote>;
144
+
145
+ /**
146
+ * Funds a Solana account with the specified token amount.
147
+ *
148
+ * @param options - The options for the fund operation.
149
+ * @param options.token - The token to fund the account with (e.g., 'usdc').
150
+ * @param options.amount - The amount of the token to fund represented as an atomic unit.
151
+ * It's common to use `parseUnits` utils from viem to convert to atomic units.
152
+ * Otherwise, you can pass atomic units directly.
153
+ *
154
+ * @returns A promise that resolves to the fund operation result containing the transfer details.
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const fundOperation = await account.fund({
159
+ * token: "usdc",
160
+ * amount: 1000000n,
161
+ * });
162
+ * ```
163
+ */
164
+ fund: (options: Omit<SolanaFundOptions, "address">) => Promise<FundOperationResult>;
165
+
166
+ /**
167
+ * Waits for a fund operation to complete and returns the transfer receipt.
168
+ *
169
+ * @param options - The options for the wait for fund operation.
170
+ * @param options.transferId - The ID of the transfer to wait for.
171
+ *
172
+ * @returns A promise that resolves to the completed transfer receipt containing details about the funding operation.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * const completedTransfer = await account.waitForFundOperationReceipt({
177
+ * transferId: "transfer_123",
178
+ * });
179
+ * ```
180
+ */
181
+ waitForFundOperationReceipt(
182
+ options: WaitForFundOperationOptions,
183
+ ): Promise<WaitForFundOperationResult>;
115
184
  };
@@ -2,13 +2,12 @@ import { Connection } from "@solana/web3.js";
2
2
 
3
3
  import {
4
4
  GENESIS_HASH_MAINNET,
5
- GENESIS_HASH_TESTNET,
6
5
  GENESIS_HASH_DEVNET,
7
6
  USDC_MAINNET_MINT_ADDRESS,
8
7
  USDC_DEVNET_MINT_ADDRESS,
9
8
  } from "./constants.js";
10
9
 
11
- export type Network = "mainnet" | "devnet" | "testnet";
10
+ export type Network = "mainnet" | "devnet";
12
11
 
13
12
  type GetOrCreateConnectionOptions = {
14
13
  networkOrConnection: Network | Connection;
@@ -33,9 +32,7 @@ export function getOrCreateConnection({
33
32
  return new Connection(
34
33
  networkOrConnection === "mainnet"
35
34
  ? "https://api.mainnet-beta.solana.com"
36
- : networkOrConnection === "devnet"
37
- ? "https://api.devnet.solana.com"
38
- : "https://api.testnet.solana.com",
35
+ : "https://api.devnet.solana.com",
39
36
  );
40
37
  }
41
38
 
@@ -43,7 +40,7 @@ export function getOrCreateConnection({
43
40
  * Get the network of the connected Solana node
44
41
  *
45
42
  * @param connection - The connection to the Solana network
46
- * @throws {Error} If the network is not mainnet, devnet, or testnet
43
+ * @throws {Error} If the network is not mainnet or devnet
47
44
  *
48
45
  * @returns The network of the connected Solana node
49
46
  */
@@ -54,11 +51,9 @@ export async function getConnectedNetwork(connection: Connection): Promise<Netwo
54
51
  return "mainnet";
55
52
  } else if (genesisHash === GENESIS_HASH_DEVNET) {
56
53
  return "devnet";
57
- } else if (genesisHash === GENESIS_HASH_TESTNET) {
58
- return "testnet";
59
54
  }
60
55
 
61
- throw new Error("Unknown network");
56
+ throw new Error("Unknown or unsupported network");
62
57
  }
63
58
 
64
59
  /**
@@ -71,9 +66,6 @@ export async function getConnectedNetwork(connection: Connection): Promise<Netwo
71
66
  export function getUsdcMintAddress(network: Network): string {
72
67
  if (network === "mainnet") {
73
68
  return USDC_MAINNET_MINT_ADDRESS;
74
- } else if (network === "devnet") {
75
- return USDC_DEVNET_MINT_ADDRESS;
76
- } else {
77
- throw new Error("Testnet is not supported for USDC");
78
69
  }
70
+ return USDC_DEVNET_MINT_ADDRESS;
79
71
  }
@@ -0,0 +1,39 @@
1
+ import { TransferStatus } from "../openapi-client/index.js";
2
+
3
+ /**
4
+ * Base options for getting a quote to fund an account.
5
+ */
6
+ export interface BaseQuoteFundOptions {
7
+ /** The address of the account. */
8
+ address: string;
9
+ /** The amount to fund the account with, in atomic units (e.g. wei for ETH, lamports for SOL) of the token. */
10
+ amount: bigint;
11
+ }
12
+
13
+ /**
14
+ * Base options for funding an account.
15
+ */
16
+ export interface BaseFundOptions {
17
+ /** The address of the account. */
18
+ address: string;
19
+ /** The amount to fund the account with, in atomic units (e.g. wei for ETH, lamports for SOL) of the token. */
20
+ amount: bigint;
21
+ }
22
+
23
+ /**
24
+ * The result of a fund operation.
25
+ */
26
+ export type FundOperationResult = {
27
+ /** The transfer that was created to fund the account. */
28
+ id: string;
29
+ /** The network that the transfer was created on. */
30
+ network: string;
31
+ /** The target amount that will be received. */
32
+ targetAmount: string;
33
+ /** The currency that will be received. */
34
+ targetCurrency: string;
35
+ /** The status of the fund operation. */
36
+ status: TransferStatus;
37
+ /** The transaction hash of the transfer. */
38
+ transactionHash?: string;
39
+ };
@@ -1,5 +1,5 @@
1
- import { CdpOpenApiClientType, Transfer, TransferStatus } from "../../../openapi-client/index.js";
2
- import { wait, WaitOptions } from "../../../utils/wait.js";
1
+ import { CdpOpenApiClientType, Transfer, TransferStatus } from "../openapi-client/index.js";
2
+ import { wait, WaitOptions } from "../utils/wait.js";
3
3
 
4
4
  /**
5
5
  * Options for waiting for a fund operation.
@@ -57,6 +57,12 @@ export const ErrorType = {
57
57
  policy_violation: "policy_violation",
58
58
  policy_in_use: "policy_in_use",
59
59
  account_limit_exceeded: "account_limit_exceeded",
60
+ network_not_tradable: "network_not_tradable",
61
+ guest_permission_denied: "guest_permission_denied",
62
+ guest_region_forbidden: "guest_region_forbidden",
63
+ guest_transaction_limit: "guest_transaction_limit",
64
+ guest_transaction_count: "guest_transaction_count",
65
+ guest_phone_number_verification_expired: "guest_phone_number_verification_expired",
60
66
  } as const;
61
67
 
62
68
  /**
@@ -143,6 +149,26 @@ Account names are guaranteed to be unique across all Smart Accounts in the devel
143
149
  updatedAt?: string;
144
150
  }
145
151
 
152
+ /**
153
+ * The network the user operation is for.
154
+ */
155
+ export type EvmUserOperationNetwork =
156
+ (typeof EvmUserOperationNetwork)[keyof typeof EvmUserOperationNetwork];
157
+
158
+ // eslint-disable-next-line @typescript-eslint/no-redeclare
159
+ export const EvmUserOperationNetwork = {
160
+ "base-sepolia": "base-sepolia",
161
+ base: "base",
162
+ arbitrum: "arbitrum",
163
+ optimism: "optimism",
164
+ zora: "zora",
165
+ polygon: "polygon",
166
+ bnb: "bnb",
167
+ avalanche: "avalanche",
168
+ ethereum: "ethereum",
169
+ "ethereum-sepolia": "ethereum-sepolia",
170
+ } as const;
171
+
146
172
  export interface EvmCall {
147
173
  /**
148
174
  * The address the call is directed to.
@@ -158,18 +184,6 @@ export interface EvmCall {
158
184
  data: string;
159
185
  }
160
186
 
161
- /**
162
- * The network the user operation is for.
163
- */
164
- export type EvmUserOperationNetwork =
165
- (typeof EvmUserOperationNetwork)[keyof typeof EvmUserOperationNetwork];
166
-
167
- // eslint-disable-next-line @typescript-eslint/no-redeclare
168
- export const EvmUserOperationNetwork = {
169
- "base-sepolia": "base-sepolia",
170
- base: "base",
171
- } as const;
172
-
173
187
  /**
174
188
  * The status of the user operation.
175
189
  */
@@ -187,7 +201,6 @@ export const EvmUserOperationStatus = {
187
201
  } as const;
188
202
 
189
203
  export interface EvmUserOperation {
190
- /** The network the user operation is for. */
191
204
  network: EvmUserOperationNetwork;
192
205
  /**
193
206
  * The hash of the user operation. This is not the transaction hash, as a transaction consists of multiple user operations. The user operation hash is the hash of this particular user operation which gets signed by the owner of the Smart Account.
@@ -609,7 +622,7 @@ export const EvmAddressCriterionOperator = {
609
622
  export interface EvmAddressCriterion {
610
623
  /** The type of criterion to use. This should be `evmAddress`. */
611
624
  type: EvmAddressCriterionType;
612
- /** A list of 0x-prefixed EVM addresses that the transaction's `to` field should be compared to. There is a limit of 100 addresses per criterion. */
625
+ /** A list of 0x-prefixed EVM addresses that the transaction's `to` field should be compared to. There is a limit of 300 addresses per criterion. */
613
626
  addresses: string[];
614
627
  /** The operator to use for the comparison. The transaction's `to` field will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
615
628
  operator: EvmAddressCriterionOperator;
@@ -1009,7 +1022,7 @@ export const EvmTypedAddressConditionOperator = {
1009
1022
  * A schema for specifying criterion for an address field of an EVM typed message. The address can be deeply nested within the typed data's message.
1010
1023
  */
1011
1024
  export interface EvmTypedAddressCondition {
1012
- /** A list of 0x-prefixed EVM addresses that the value located at the message's path should be compared to. There is a limit of 100 addresses per criterion. */
1025
+ /** A list of 0x-prefixed EVM addresses that the value located at the message's path should be compared to. There is a limit of 300 addresses per criterion. */
1013
1026
  addresses: string[];
1014
1027
  /** The operator to use for the comparison. The value located at the message's path will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
1015
1028
  operator: EvmTypedAddressConditionOperator;
@@ -1135,7 +1148,7 @@ export const SignEvmTypedDataVerifyingContractCriterionOperator = {
1135
1148
  export interface SignEvmTypedDataVerifyingContractCriterion {
1136
1149
  /** The type of criterion to use. This should be `evmTypedDataVerifyingContract`. */
1137
1150
  type: SignEvmTypedDataVerifyingContractCriterionType;
1138
- /** A list of 0x-prefixed EVM addresses that the domain's verifying contract should be compared to. There is a limit of 100 addresses per criterion. */
1151
+ /** A list of 0x-prefixed EVM addresses that the domain's verifying contract should be compared to. There is a limit of 300 addresses per criterion. */
1139
1152
  addresses: string[];
1140
1153
  /** The operator to use for the comparison. The domain's verifying contract will be on the left-hand side of the operator, and the `addresses` field will be on the right-hand side. */
1141
1154
  operator: SignEvmTypedDataVerifyingContractCriterionOperator;
@@ -1947,21 +1960,8 @@ Account names must be unique across all EVM smart accounts in the developer's CD
1947
1960
  name?: string;
1948
1961
  };
1949
1962
 
1950
- /**
1951
- * The network to prepare the user operation for.
1952
- */
1953
- export type PrepareUserOperationBodyNetwork =
1954
- (typeof PrepareUserOperationBodyNetwork)[keyof typeof PrepareUserOperationBodyNetwork];
1955
-
1956
- // eslint-disable-next-line @typescript-eslint/no-redeclare
1957
- export const PrepareUserOperationBodyNetwork = {
1958
- "base-sepolia": "base-sepolia",
1959
- base: "base",
1960
- } as const;
1961
-
1962
1963
  export type PrepareUserOperationBody = {
1963
- /** The network to prepare the user operation for. */
1964
- network: PrepareUserOperationBodyNetwork;
1964
+ network: EvmUserOperationNetwork;
1965
1965
  /** The list of calls to make from the Smart Account. */
1966
1966
  calls: EvmCall[];
1967
1967
  /** The URL of the paymaster to use for the user operation. */
@@ -9,6 +9,7 @@ import { faker } from "@faker-js/faker";
9
9
 
10
10
  import { HttpResponse, delay, http } from "msw";
11
11
 
12
+ import { EvmUserOperationNetwork } from "../coinbaseDeveloperPlatformAPIs.schemas.js";
12
13
  import type {
13
14
  EvmSmartAccount,
14
15
  EvmUserOperation,
@@ -172,7 +173,7 @@ export const getUpdateEvmSmartAccountResponseMock = (
172
173
  export const getPrepareUserOperationResponseMock = (
173
174
  overrideResponse: Partial<EvmUserOperation> = {},
174
175
  ): EvmUserOperation => ({
175
- network: faker.helpers.arrayElement(["base-sepolia", "base"] as const),
176
+ network: faker.helpers.arrayElement(Object.values(EvmUserOperationNetwork)),
176
177
  userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
177
178
  calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
178
179
  to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
@@ -197,7 +198,7 @@ export const getPrepareUserOperationResponseMock = (
197
198
  export const getGetUserOperationResponseMock = (
198
199
  overrideResponse: Partial<EvmUserOperation> = {},
199
200
  ): EvmUserOperation => ({
200
- network: faker.helpers.arrayElement(["base-sepolia", "base"] as const),
201
+ network: faker.helpers.arrayElement(Object.values(EvmUserOperationNetwork)),
201
202
  userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
202
203
  calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
203
204
  to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
@@ -222,7 +223,7 @@ export const getGetUserOperationResponseMock = (
222
223
  export const getSendUserOperationResponseMock = (
223
224
  overrideResponse: Partial<EvmUserOperation> = {},
224
225
  ): EvmUserOperation => ({
225
- network: faker.helpers.arrayElement(["base-sepolia", "base"] as const),
226
+ network: faker.helpers.arrayElement(Object.values(EvmUserOperationNetwork)),
226
227
  userOpHash: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{64}$"),
227
228
  calls: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
228
229
  to: faker.helpers.fromRegExp("^0x[0-9a-fA-F]{40}$"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.27.0",
3
+ "version": "1.29.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",
@@ -66,9 +66,9 @@ export const EvmAddressCriterionSchema = z.object({
66
66
  /**
67
67
  * Array of EVM addresses to compare against.
68
68
  * Each address must be a 0x-prefixed 40-character hexadecimal string.
69
- * Limited to a maximum of 100 addresses per criterion.
69
+ * Limited to a maximum of 300 addresses per criterion.
70
70
  */
71
- addresses: z.array(Address).max(100),
71
+ addresses: z.array(Address).max(300),
72
72
  /**
73
73
  * The operator to use for evaluating transaction addresses.
74
74
  * "in" checks if an address is in the provided list.
@@ -128,9 +128,9 @@ export const EvmTypedAddressConditionSchema = z.object({
128
128
  /**
129
129
  * Array of EVM addresses to compare against.
130
130
  * Each address must be a 0x-prefixed 40-character hexadecimal string.
131
- * Limited to a maximum of 100 addresses per condition.
131
+ * Limited to a maximum of 300 addresses per condition.
132
132
  */
133
- addresses: z.array(Address).max(100),
133
+ addresses: z.array(Address).max(300),
134
134
  /**
135
135
  * The operator to use for evaluating addresses.
136
136
  * "in" checks if an address is in the provided list.
@@ -235,9 +235,9 @@ export const SignEvmTypedDataVerifyingContractCriterionSchema = z.object({
235
235
  /**
236
236
  * Array of EVM addresses allowed or disallowed as verifying contracts.
237
237
  * Each address must be a 0x-prefixed 40-character hexadecimal string.
238
- * Limited to a maximum of 100 addresses per criterion.
238
+ * Limited to a maximum of 300 addresses per criterion.
239
239
  */
240
- addresses: z.array(Address).max(100),
240
+ addresses: z.array(Address).max(300),
241
241
  /**
242
242
  * The operator to use for evaluating verifying contract addresses.
243
243
  * "in" checks if the verifying contract is in the provided list.
package/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.27.0";
1
+ export const version = "1.29.0";
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Quote = void 0;
4
- /**
5
- * A class representing a funding quote that can be executed.
6
- */
7
- class Quote {
8
- /** Quote for the transfer. */
9
- quoteId;
10
- /** Network to transfer the funds to. */
11
- network;
12
- /** The amount in fiat currency. */
13
- fiatAmount;
14
- /** The fiat currency. */
15
- fiatCurrency;
16
- /** The amount in the token to transfer. */
17
- tokenAmount;
18
- /** The token to transfer. */
19
- token;
20
- /** Fees in the token to transfer. */
21
- fees;
22
- apiClient;
23
- /**
24
- * Creates a new Quote instance.
25
- *
26
- * @param apiClient - The API client.
27
- * @param quoteId - The quote ID.
28
- * @param network - The network to transfer funds to.
29
- * @param fiatAmount - The amount in fiat currency.
30
- * @param fiatCurrency - The fiat currency.
31
- * @param tokenAmount - The amount in the token to transfer.
32
- * @param token - The token to transfer.
33
- * @param fees - Fees for the transfer.
34
- */
35
- constructor(apiClient, quoteId, network, fiatAmount, fiatCurrency, tokenAmount, token, fees) {
36
- this.apiClient = apiClient;
37
- this.quoteId = quoteId;
38
- this.network = network;
39
- this.fiatAmount = fiatAmount;
40
- this.fiatCurrency = fiatCurrency;
41
- this.tokenAmount = tokenAmount;
42
- this.token = token;
43
- this.fees = fees;
44
- }
45
- /**
46
- * Executes the quote to perform the actual fund transfer.
47
- *
48
- * @returns A promise that resolves to the result of the executed quote.
49
- */
50
- async execute() {
51
- const transfer = await this.apiClient.executePaymentTransferQuote(this.quoteId);
52
- return {
53
- id: transfer.id,
54
- network: transfer.target.network,
55
- targetAmount: transfer.targetAmount,
56
- targetCurrency: transfer.targetCurrency,
57
- status: transfer.status,
58
- transactionHash: transfer.transactionHash,
59
- };
60
- }
61
- }
62
- exports.Quote = Quote;
63
- //# sourceMappingURL=Quote.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Quote.js","sourceRoot":"","sources":["../../../../actions/evm/fund/Quote.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,KAAK;IAChB,8BAA8B;IACvB,OAAO,CAAS;IACvB,wCAAwC;IACjC,OAAO,CAAsB;IACpC,mCAAmC;IAC5B,UAAU,CAAS;IAC1B,yBAAyB;IAClB,YAAY,CAAS;IAC5B,2CAA2C;IACpC,WAAW,CAAS;IAC3B,6BAA6B;IACtB,KAAK,CAAS;IACrB,qCAAqC;IAC9B,IAAI,CAKP;IAEI,SAAS,CAAuB;IAExC;;;;;;;;;;;OAWG;IACH,YACE,SAA+B,EAC/B,OAAe,EACf,OAA4B,EAC5B,UAAkB,EAClB,YAAoB,EACpB,WAAmB,EACnB,KAAa,EACb,IAIG;QAEH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,2BAA2B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEhF,OAAO;YACL,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO;YAChC,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,eAAe,EAAE,QAAQ,CAAC,eAAe;SAC1C,CAAC;IACJ,CAAC;CACF;AA5ED,sBA4EC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"waitForFundOperationReceipt.js","sourceRoot":"","sources":["../../../../actions/evm/fund/waitForFundOperationReceipt.ts"],"names":[],"mappings":";;AAuEA,kEAwCC;AA/GD,+DAAkG;AAClG,oDAA2D;AAmD3D;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,UAAU,2BAA2B,CAC/C,MAA4B,EAC5B,OAAoC;IAEpC,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAE/B,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;QACxB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC7D,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;IAEF,MAAM,SAAS,GAAG,CAAC,SAAmB,EAA8B,EAAE;QACpE,IAAI,SAAS,CAAC,MAAM,KAAK,yBAAc,CAAC,MAAM,EAAE,CAAC;YAC/C,OAAO;gBACL,EAAE,EAAE,SAAS,CAAC,EAAE;gBAChB,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO;gBACjC,YAAY,EAAE,SAAS,CAAC,YAAY;gBACpC,cAAc,EAAE,SAAS,CAAC,cAAc;gBACxC,MAAM,EAAE,SAAS,CAAC,MAAM;aACK,CAAC;QAClC,CAAC;aAAM,IAAI,SAAS,CAAC,MAAM,KAAK,yBAAc,CAAC,SAAS,EAAE,CAAC;YACzD,OAAO;gBACL,EAAE,EAAE,SAAS,CAAC,EAAE;gBAChB,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO;gBACjC,YAAY,EAAE,SAAS,CAAC,YAAY;gBACpC,cAAc,EAAE,SAAS,CAAC,cAAc;gBACxC,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,eAAe,EAAE,SAAS,CAAC,eAAgB;aACX,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI;QACzC,cAAc,EAAE,GAAG;QACnB,eAAe,EAAE,CAAC;KACnB,CAAC;IAEF,OAAO,MAAM,IAAA,cAAI,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,SAAmB,EAAW,EAAE;IAClD,OAAO,CACL,SAAS,CAAC,MAAM,KAAK,yBAAc,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,yBAAc,CAAC,MAAM,CAC5F,CAAC;AACJ,CAAC,CAAC"}