@coinbase/cdp-core 0.0.33 → 0.0.34

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 (59) hide show
  1. package/README.md +74 -8
  2. package/dist/esm/index.native.js +40 -37
  3. package/dist/esm/index.native14.js +6 -5
  4. package/dist/esm/index.native15.js +12 -10
  5. package/dist/esm/index.native17.js +1 -0
  6. package/dist/esm/index.native54.js +1 -1
  7. package/dist/esm/index.native55.js +1 -1
  8. package/dist/esm/index.native57.js +2 -2
  9. package/dist/esm/index.native59.js +1 -1
  10. package/dist/esm/index.native6.js +188 -134
  11. package/dist/esm/index.native82.js +2 -21
  12. package/dist/esm/index.native83.js +21 -2
  13. package/dist/esm/index.native84.js +18 -102
  14. package/dist/esm/index.native85.js +80 -20
  15. package/dist/esm/index.native86.js +103 -79
  16. package/dist/esm/index.native95.js +1 -1
  17. package/dist/esm/index.web.js +41 -38
  18. package/dist/esm/index.web12.js +6 -5
  19. package/dist/esm/index.web13.js +12 -10
  20. package/dist/esm/index.web15.js +1 -0
  21. package/dist/esm/index.web26.js +1 -1
  22. package/dist/esm/index.web5.js +188 -134
  23. package/dist/esm/index.web84.js +1 -1
  24. package/dist/esm/index.web93.js +10 -79
  25. package/dist/esm/index.web94.js +79 -10
  26. package/dist/native/index.native.js +40 -37
  27. package/dist/native/index.native14.js +6 -5
  28. package/dist/native/index.native15.js +12 -10
  29. package/dist/native/index.native17.js +1 -0
  30. package/dist/native/index.native54.js +1 -1
  31. package/dist/native/index.native55.js +1 -1
  32. package/dist/native/index.native57.js +2 -2
  33. package/dist/native/index.native59.js +1 -1
  34. package/dist/native/index.native6.js +188 -134
  35. package/dist/native/index.native82.js +2 -21
  36. package/dist/native/index.native83.js +21 -2
  37. package/dist/native/index.native84.js +18 -102
  38. package/dist/native/index.native85.js +80 -20
  39. package/dist/native/index.native86.js +103 -79
  40. package/dist/native/index.native95.js +1 -1
  41. package/dist/native-types/auth/withAuth.d.ts +3 -1
  42. package/dist/native-types/core.d.ts +3 -1
  43. package/dist/native-types/types.d.ts +20 -3
  44. package/dist/types/auth/withAuth.d.ts +3 -1
  45. package/dist/types/core.d.ts +3 -1
  46. package/dist/types/types.d.ts +20 -3
  47. package/dist/web/index.web.js +41 -38
  48. package/dist/web/index.web12.js +6 -5
  49. package/dist/web/index.web13.js +12 -10
  50. package/dist/web/index.web15.js +1 -0
  51. package/dist/web/index.web26.js +1 -1
  52. package/dist/web/index.web5.js +188 -134
  53. package/dist/web/index.web84.js +1 -1
  54. package/dist/web/index.web93.js +10 -79
  55. package/dist/web/index.web94.js +79 -10
  56. package/dist/web-types/auth/withAuth.d.ts +3 -1
  57. package/dist/web-types/core.d.ts +3 -1
  58. package/dist/web-types/types.d.ts +20 -3
  59. package/package.json +2 -2
package/README.md CHANGED
@@ -48,10 +48,11 @@ const config: Config = {
48
48
  await initialize(config);
49
49
  ```
50
50
 
51
- #### Smart Account Configuration
51
+ #### Account Configuration
52
52
 
53
- You can configure the SDK to automatically create Smart Accounts for new users by setting `createAccountOnLogin` to `"evm-smart"`:
53
+ You can configure the SDK to create different types of accounts for new users:
54
54
 
55
+ **Smart Account Configuration:**
55
56
  ```ts lines
56
57
  const config: Config = {
57
58
  projectId: "your-project-id",
@@ -66,6 +67,20 @@ When `createAccountOnLogin` is set to `"evm-smart"`, the SDK will:
66
67
  2. Use that EOA as the owner to create a Smart Account
67
68
  3. Both accounts will be available on the user object
68
69
 
70
+ **Solana Account Configuration:**
71
+ ```ts lines
72
+ const config: Config = {
73
+ projectId: "your-project-id",
74
+ createAccountOnLogin: "solana", // Creates Solana accounts instead of EVM accounts
75
+ }
76
+
77
+ await initialize(config);
78
+ ```
79
+
80
+ When `createAccountOnLogin` is set to `"solana"`, the SDK will:
81
+ 1. Create a Solana account for new users
82
+ 2. The Solana account will be available on the `solanaAccounts` property
83
+
69
84
  ### Sign In a User
70
85
 
71
86
  You're now ready to start calling the APIs provided by the package!
@@ -102,17 +117,27 @@ if (signedIn) {
102
117
  // Get the user's information
103
118
  const user = await getCurrentUser();
104
119
  console.log("User ID:", user.userId);
105
- console.log("EVM Accounts (EOAs):", user.evmAccounts);
106
- console.log("EVM Smart Accounts:", user.evmSmartAccounts);
120
+
121
+ // Display different account types based on configuration
122
+ if (user.evmAccounts?.length > 0) {
123
+ console.log("EVM Accounts (EOAs):", user.evmAccounts);
124
+ }
125
+ if (user.evmSmartAccounts?.length > 0) {
126
+ console.log("EVM Smart Accounts:", user.evmSmartAccounts);
127
+ }
128
+ if (user.solanaAccounts?.length > 0) {
129
+ console.log("Solana Accounts:", user.solanaAccounts);
130
+ }
107
131
 
108
132
  // Find the user's email address (if they logged in with email/otp)
109
133
  const email = user.authenticationMethods.email?.email;
110
- console.log("Email Address": email)
134
+ console.log("Email Address:", email);
111
135
  }
112
136
  ```
113
137
 
114
- ### Send a Transaction
115
- We support signing and sending a Blockchain transaction in a single call on the following networks:
138
+ ### Send an EVM Transaction
139
+
140
+ We support signing and sending an EVM transaction in a single call on the following networks:
116
141
  - Base
117
142
  - Base Sepolia
118
143
  - Ethereum
@@ -145,7 +170,7 @@ const result = await sendEvmTransaction({
145
170
  console.log("Transaction Hash:", result.transactionHash);
146
171
  ```
147
172
 
148
- For networks other than those supported by the CDP APIs, your end user must sign the transaction, and then
173
+ For EVM networks other than those supported by the CDP APIs, your end user must sign the transaction, and then
149
174
  you must broadcast the transaction yourself. This example uses the public client from `viem` to broadcast the transaction.
150
175
 
151
176
  ```typescript lines
@@ -186,6 +211,47 @@ const hash = await client.sendRawTransaction({
186
211
 
187
212
  Smart Accounts provide advanced account abstraction features, including user operations and paymaster support.
188
213
 
214
+ ### Sign a Solana Transaction
215
+
216
+ When your application is configured with `createAccountOnLogin: "solana"`, you can sign Solana transactions:
217
+
218
+ ```typescript lines
219
+ import { signSolanaTransaction, getCurrentUser } from "@coinbase/cdp-core";
220
+
221
+ const user = await getCurrentUser();
222
+ const solanaAccount = user.solanaAccounts[0];
223
+
224
+ const result = await signSolanaTransaction({
225
+ solanaAccount,
226
+ transaction: "base64-encoded-solana-transaction" // Your Solana transaction here
227
+ });
228
+
229
+ console.log("Signed Transaction:", result.signedTransaction);
230
+ // The signedTransaction can now be broadcast to the Solana network
231
+ ```
232
+
233
+ ### Send a Solana Transaction
234
+
235
+ You can sign and send a Solana transaction in a single call on the following Solana networks:
236
+ - Solana Mainnet
237
+ - Solana Devnet
238
+
239
+ ```typescript lines
240
+ import { sendSolanaTransaction, getCurrentUser } from "@coinbase/cdp-core";
241
+
242
+ const user = await getCurrentUser();
243
+ const solanaAccount = user.solanaAccounts[0];
244
+
245
+ const result = await sendSolanaTransaction({
246
+ solanaAccount,
247
+ network: "solana-devnet", // or "solana" for mainnet
248
+ transaction: "base64-encoded-solana-transaction" // Your Solana transaction here
249
+ });
250
+
251
+ console.log("Transaction Signature:", result.transactionSignature);
252
+ // The transaction has been broadcast to the Solana network
253
+ ```
254
+
189
255
  #### Send User Operations
190
256
 
191
257
  Send user operations from a Smart Account:
@@ -1,49 +1,52 @@
1
1
  import { nativeCrypto as r } from "./index.native2.js";
2
- import { nativeSecureStorage as e } from "./index.native3.js";
3
- import { nativeStorage as o } from "./index.native4.js";
2
+ import { nativeSecureStorage as o } from "./index.native3.js";
3
+ import { nativeStorage as e } from "./index.native4.js";
4
4
  import { setPlatformServices as t } from "./index.native5.js";
5
- import { exportEvmAccount as f, getAccessToken as v, getCurrentUser as d, getUserOperation as S, initialize as u, isSignedIn as T, onAuthStateChange as A, sendEvmTransaction as l, sendUserOperation as x, signEvmHash as y, signEvmMessage as h, signEvmTransaction as O, signEvmTypedData as P, signInWithEmail as C, signInWithSms as D, signOut as I, verifyEmailOTP as R, verifySmsOTP as U } from "./index.native6.js";
6
- import { AuthManager as M } from "./index.native7.js";
7
- import { APIError as H, ErrorType as N, HttpErrorType as _, SendEvmTransactionWithEndUserAccountBodyNetwork as b } from "@coinbase/cdp-api-client";
5
+ import { exportEvmAccount as d, getAccessToken as S, getCurrentUser as f, getUserOperation as v, initialize as T, isSignedIn as u, onAuthStateChange as l, sendEvmTransaction as A, sendSolanaTransaction as y, sendUserOperation as h, signEvmHash as x, signEvmMessage as O, signEvmTransaction as P, signEvmTypedData as C, signInWithEmail as D, signInWithSms as I, signOut as R, signSolanaTransaction as U, verifyEmailOTP as W, verifySmsOTP as k } from "./index.native6.js";
6
+ import { AuthManager as N } from "./index.native7.js";
7
+ import { APIError as B, ErrorType as H, HttpErrorType as _, SendEvmTransactionWithEndUserAccountBodyNetwork as b, SendSolanaTransactionWithEndUserAccountBodyNetwork as z } from "@coinbase/cdp-api-client";
8
8
  import "viem";
9
- import { createCDPEmbeddedWallet as z } from "./index.native8.js";
10
- import { EIP1193ProviderError as V, STANDARD_ERROR_CODES as j } from "./index.native9.js";
9
+ import { createCDPEmbeddedWallet as j } from "./index.native8.js";
10
+ import { EIP1193ProviderError as F, STANDARD_ERROR_CODES as G } from "./index.native9.js";
11
11
  import "ox";
12
12
  import "zustand";
13
- import { toViemAccount as F } from "./index.native10.js";
14
- import { ModuleResolutionError as J } from "./index.native11.js";
13
+ import { toViemAccount as K } from "./index.native10.js";
14
+ import { ModuleResolutionError as Q } from "./index.native11.js";
15
15
  t({
16
16
  crypto: r,
17
- storage: o,
18
- secureStorage: e
17
+ storage: e,
18
+ secureStorage: o
19
19
  });
20
20
  export {
21
- H as APIError,
22
- M as AuthManager,
23
- V as EIP1193ProviderError,
24
- N as ErrorType,
21
+ B as APIError,
22
+ N as AuthManager,
23
+ F as EIP1193ProviderError,
24
+ H as ErrorType,
25
25
  _ as HttpErrorType,
26
- J as ModuleResolutionError,
27
- j as STANDARD_ERROR_CODES,
26
+ Q as ModuleResolutionError,
27
+ G as STANDARD_ERROR_CODES,
28
28
  b as SendEvmTransactionWithEndUserAccountBodyNetwork,
29
- z as createCDPEmbeddedWallet,
30
- f as exportEvmAccount,
31
- v as getAccessToken,
32
- d as getCurrentUser,
33
- S as getUserOperation,
34
- u as initialize,
35
- T as isSignedIn,
36
- A as onAuthStateChange,
37
- l as sendEvmTransaction,
38
- x as sendUserOperation,
39
- y as signEvmHash,
40
- h as signEvmMessage,
41
- O as signEvmTransaction,
42
- P as signEvmTypedData,
43
- C as signInWithEmail,
44
- D as signInWithSms,
45
- I as signOut,
46
- F as toViemAccount,
47
- R as verifyEmailOTP,
48
- U as verifySmsOTP
29
+ z as SendSolanaTransactionWithEndUserAccountBodyNetwork,
30
+ j as createCDPEmbeddedWallet,
31
+ d as exportEvmAccount,
32
+ S as getAccessToken,
33
+ f as getCurrentUser,
34
+ v as getUserOperation,
35
+ T as initialize,
36
+ u as isSignedIn,
37
+ l as onAuthStateChange,
38
+ A as sendEvmTransaction,
39
+ y as sendSolanaTransaction,
40
+ h as sendUserOperation,
41
+ x as signEvmHash,
42
+ O as signEvmMessage,
43
+ P as signEvmTransaction,
44
+ C as signEvmTypedData,
45
+ D as signInWithEmail,
46
+ I as signInWithSms,
47
+ R as signOut,
48
+ U as signSolanaTransaction,
49
+ K as toViemAccount,
50
+ W as verifyEmailOTP,
51
+ k as verifySmsOTP
49
52
  };
@@ -1,17 +1,18 @@
1
1
  import "@coinbase/cdp-api-client";
2
- const r = (u, c, e) => {
3
- const s = new Date(c).getTime(), m = {
2
+ const m = (c, a, e) => {
3
+ const s = new Date(a).getTime(), u = {
4
4
  userId: e.userId,
5
5
  evmAccounts: e.evmAccounts?.map((t) => t) ?? [],
6
6
  evmSmartAccounts: e.evmSmartAccounts?.map((t) => t) ?? [],
7
+ solanaAccounts: e.solanaAccounts?.map((t) => t) ?? [],
7
8
  authenticationMethods: e.authenticationMethods.reduce((t, o) => (t[o.type] = o, t), {})
8
9
  };
9
10
  return {
10
- accessToken: u,
11
+ accessToken: c,
11
12
  expiresAt: s,
12
- user: m
13
+ user: u
13
14
  };
14
15
  };
15
16
  export {
16
- r as toAuthState
17
+ m as toAuthState
17
18
  };
@@ -1,18 +1,20 @@
1
1
  import "@coinbase/cdp-api-client";
2
2
  import "viem";
3
- const o = async (t) => await t.isSignedIn();
4
- async function w(t, n, e) {
5
- if (!await o(n))
3
+ const i = async (n) => await n.isSignedIn();
4
+ async function f(n, r, o) {
5
+ if (!await i(r))
6
6
  throw new Error("User not signed in");
7
- const r = await n.getUser();
8
- if ("evmAccount" in t && !r.evmAccounts?.find((c) => c === t.evmAccount))
7
+ const c = await r.getUser();
8
+ if ("evmAccount" in n && !c.evmAccounts?.find((t) => t === n.evmAccount))
9
9
  throw new Error("EVM account not found");
10
- if ("evmSmartAccount" in t && !r.evmSmartAccounts?.find((c) => c === t.evmSmartAccount))
10
+ if ("evmSmartAccount" in n && !c.evmSmartAccounts?.find((t) => t === n.evmSmartAccount))
11
11
  throw new Error("EVM Smart Account not found");
12
- const i = await n.getWalletSecretId();
13
- return e({ ...t, user: r, walletSecretId: i });
12
+ if ("solanaAccount" in n && !c.solanaAccounts?.find((t) => t === n.solanaAccount))
13
+ throw new Error("Solana account not found");
14
+ const e = await r.getWalletSecretId();
15
+ return o({ ...n, user: c, walletSecretId: e });
14
16
  }
15
17
  export {
16
- o as isSignedIn,
17
- w as withAuth
18
+ i as isSignedIn,
19
+ f as withAuth
18
20
  };
@@ -3,6 +3,7 @@ import "viem";
3
3
  const t = "0x0000000000000000000000000000000000000000", s = {
4
4
  userId: "mock-user-id",
5
5
  evmAccounts: [t],
6
+ solanaAccounts: ["5fNfvyp5f3BB9T24s6bC8QjDXuJqvU8WjziJpEQi9PWT"],
6
7
  authenticationMethods: {
7
8
  email: {
8
9
  type: "email",
@@ -1,4 +1,4 @@
1
- import { version as o } from "./index.native83.js";
1
+ import { version as o } from "./index.native82.js";
2
2
  let r = {
3
3
  getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
4
4
  version: `viem@${o}`
@@ -1,4 +1,4 @@
1
- import { NegativeOffsetError as o, PositionOutOfBoundsError as e, RecursiveReadLimitExceededError as n } from "./index.native82.js";
1
+ import { NegativeOffsetError as o, PositionOutOfBoundsError as e, RecursiveReadLimitExceededError as n } from "./index.native83.js";
2
2
  const h = {
3
3
  bytes: new Uint8Array(),
4
4
  dataView: new DataView(new ArrayBuffer(0)),
@@ -1,5 +1,5 @@
1
- import { split as L, rotlSH as T, rotlSL as S, rotlBH as m, rotlBL as F } from "./index.native85.js";
2
- import { createHasher as X, Hash as E, anumber as d, u32 as U, swap32IfBE as I, aexists as x, toBytes as P, abytes as k, aoutput as M, clean as y } from "./index.native86.js";
1
+ import { split as L, rotlSH as T, rotlSL as S, rotlBH as m, rotlBL as F } from "./index.native84.js";
2
+ import { createHasher as X, Hash as E, anumber as d, u32 as U, swap32IfBE as I, aexists as x, toBytes as P, abytes as k, aoutput as M, clean as y } from "./index.native85.js";
3
3
  const R = BigInt(0), f = BigInt(1), j = BigInt(2), q = BigInt(7), v = BigInt(256), z = BigInt(113), _ = [], g = [], B = [];
4
4
  for (let n = 0, t = f, s = 1, i = 0; n < 24; n++) {
5
5
  [s, i] = [i, (2 * s + 3 * i) % 5], _.push(2 * (5 * i + s)), g.push((n + 1) * (n + 2) / 2 % 64);
@@ -1,4 +1,4 @@
1
- import { sha256 as s } from "./index.native84.js";
1
+ import { sha256 as s } from "./index.native86.js";
2
2
  const o = s;
3
3
  export {
4
4
  o as sha256