@coinbase/cdp-core 0.0.19 → 0.0.21

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.
package/README.md CHANGED
@@ -48,6 +48,24 @@ const config: Config = {
48
48
  await initialize(config);
49
49
  ```
50
50
 
51
+ #### Smart Account Configuration
52
+
53
+ You can configure the SDK to automatically create Smart Accounts for new users by setting `createAccountOnLogin` to `"evm-smart"`:
54
+
55
+ ```ts
56
+ const config: Config = {
57
+ projectId: "your-project-id",
58
+ createAccountOnLogin: "evm-smart", // Creates Smart Accounts instead of EOAs
59
+ }
60
+
61
+ await initialize(config);
62
+ ```
63
+
64
+ When `createAccountOnLogin` is set to `"evm-smart"`, the SDK will:
65
+ 1. Create an EOA (Externally Owned Account) first
66
+ 2. Use that EOA as the owner to create a Smart Account
67
+ 3. Both accounts will be available on the user object
68
+
51
69
  ### Sign In a User
52
70
 
53
71
  You're now ready to start calling the APIs provided by the package!
@@ -84,7 +102,8 @@ if (signedIn) {
84
102
  // Get the user's information
85
103
  const user = await getCurrentUser();
86
104
  console.log("User ID:", user.userId);
87
- console.log("EVM Accounts:", user.evmAccounts);
105
+ console.log("EVM Accounts (EOAs):", user.evmAccounts);
106
+ console.log("EVM Smart Accounts:", user.evmSmartAccounts);
88
107
 
89
108
  // Find the user's email address (if they logged in with email/otp)
90
109
  const email = user.authenticationMethods.email?.email;
@@ -93,7 +112,15 @@ if (signedIn) {
93
112
  ```
94
113
 
95
114
  ### Send a Transaction
96
- We support signing and sending a Blockchain transaction in a single call on Base or Base Sepolia:
115
+ We support signing and sending a Blockchain transaction in a single call on the following networks:
116
+ - Base
117
+ - Base Sepolia
118
+ - Ethereum
119
+ - Ethereum Sepolia
120
+ - Avalanche
121
+ - Arbitrum
122
+ - Optimism
123
+ - Polygon
97
124
 
98
125
  ```typescript
99
126
  import { sendEvmTransaction, getCurrentUser } from "@coinbase/cdp-core";
@@ -118,13 +145,13 @@ const result = await sendEvmTransaction({
118
145
  console.log("Transaction Hash:", result.transactionHash);
119
146
  ```
120
147
 
121
- For networks other than Base or Base Sepolia, your end user must sign the transaction, and then
148
+ For networks other than those supported by the CDP APIs, your end user must sign the transaction, and then
122
149
  you must broadcast the transaction yourself. This example uses the public client from `viem` to broadcast the transaction.
123
150
 
124
151
  ```typescript
125
152
  import { signEvmTransaction, getCurrentUser } from "@coinbase/cdp-core";
126
153
  import { http, createPublicClient } from "viem";
127
- import { sepolia } from "viem/chains";
154
+ import { tron } from "viem/chains";
128
155
 
129
156
  const user = await getCurrentUser();
130
157
  const evmAccount = user.evmAccounts[0];
@@ -139,14 +166,14 @@ const { signedTransaction } = await signEvmTransaction({
139
166
  gas: 21000n,
140
167
  maxFeePerGas: 30000000000n,
141
168
  maxPriorityFeePerGas: 1000000000n,
142
- chainId: 11155111, // Sepolia
169
+ chainId: 728126428, // Tron
143
170
  type: "eip1559",
144
171
  }
145
172
  });
146
173
 
147
174
  // Broadcast signed transaction to non-Base chain
148
175
  const client = createPublicClient({
149
- chain: sepolia,
176
+ chain: tron,
150
177
  transport: http()
151
178
  });
152
179
 
@@ -155,6 +182,61 @@ const hash = await client.sendRawTransaction({
155
182
  });
156
183
  ```
157
184
 
185
+ ### Smart Account Operations
186
+
187
+ Smart Accounts provide advanced account abstraction features, including user operations and paymaster support.
188
+
189
+ #### Send User Operations
190
+
191
+ Send user operations from a Smart Account:
192
+
193
+ ```typescript
194
+ import { sendUserOperation, getCurrentUser } from "@coinbase/cdp-core";
195
+
196
+ const user = await getCurrentUser();
197
+ const smartAccount = user.evmSmartAccounts[0];
198
+
199
+ const result = await sendUserOperation({
200
+ evmSmartAccount: smartAccount,
201
+ network: "base-sepolia",
202
+ calls: [
203
+ {
204
+ to: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
205
+ value: 1000000000000000000n, // 1 ETH in wei
206
+ data: "0x", // Optional contract interaction data
207
+ }
208
+ ],
209
+ // Optional paymaster for gas sponsorship. Get your free Base paymaster URL [from the CDP Portal](https://portal.cdp.coinbase.com/products/node).
210
+ paymasterUrl: "https://paymaster.example.com",
211
+ });
212
+
213
+ console.log("User Operation Hash:", result.userOperationHash);
214
+ ```
215
+
216
+ #### Get User Operation Status
217
+
218
+ After sending a user operation, you can get its status and retrieve the result:
219
+
220
+ ```typescript
221
+ import { getUserOperation } from "@coinbase/cdp-core";
222
+
223
+ // Get the status of a user operation
224
+ const userOperationResult = await getUserOperation({
225
+ userOperationHash: result.userOperationHash,
226
+ evmSmartAccount: smartAccount,
227
+ network: "base-sepolia"
228
+ });
229
+
230
+ console.log("Status:", userOperationResult.status); // "pending", "complete", or "failed"
231
+
232
+ if (userOperationResult.status === "complete") {
233
+ console.log("Transaction Hash:", userOperationResult.transactionHash);
234
+ console.log("Block Number:", userOperationResult.receipts?.[0]?.blockNumber);
235
+ } else if (userOperationResult.status === "failed") {
236
+ console.log("Failure reason:", userOperationResult.receipts?.[0]?.revert?.message);
237
+ }
238
+ ```
239
+
158
240
  ### Sign Messages and Typed Data
159
241
 
160
242
  End users can sign EVM messages, hashes, and typed data to generate signatures for various onchain applications.
package/dist/esm/index.js CHANGED
@@ -1,34 +1,36 @@
1
- import { exportEvmAccount as n, getAccessToken as m, getCurrentUser as s, initialize as E, isSignedIn as a, onAuthStateChange as p, sendEvmTransaction as c, signEvmHash as g, signEvmMessage as d, signEvmTransaction as v, signEvmTypedData as T, signInWithEmail as A, signInWithSms as f, signOut as S, verifyEmailOTP as h, verifySmsOTP as u } from "./index2.js";
2
- import { APIError as y, ErrorType as P, HttpErrorType as l, SendEvmTransactionWithEndUserAccountBodyNetwork as D } from "@coinbase/cdp-api-client";
1
+ import { exportEvmAccount as i, getAccessToken as s, getCurrentUser as m, getUserOperation as a, initialize as E, isSignedIn as p, onAuthStateChange as g, sendEvmTransaction as c, sendUserOperation as d, signEvmHash as v, signEvmMessage as T, signEvmTransaction as A, signEvmTypedData as f, signInWithEmail as O, signInWithSms as S, signOut as h, verifyEmailOTP as u, verifySmsOTP as x } from "./index2.js";
2
+ import { APIError as P, ErrorType as l, HttpErrorType as D, SendEvmTransactionWithEndUserAccountBodyNetwork as I } from "@coinbase/cdp-api-client";
3
3
  import "viem";
4
- import { createCDPEmbeddedWallet as O } from "./index3.js";
5
- import { EIP1193ProviderError as R, STANDARD_ERROR_CODES as W } from "./index4.js";
4
+ import { createCDPEmbeddedWallet as R } from "./index3.js";
5
+ import { EIP1193ProviderError as W, STANDARD_ERROR_CODES as k } from "./index4.js";
6
6
  import "ox";
7
7
  import "zustand";
8
- import { toViemAccount as H } from "./index5.js";
8
+ import { toViemAccount as N } from "./index5.js";
9
9
  export {
10
- y as APIError,
11
- R as EIP1193ProviderError,
12
- P as ErrorType,
13
- l as HttpErrorType,
14
- W as STANDARD_ERROR_CODES,
15
- D as SendEvmTransactionWithEndUserAccountBodyNetwork,
16
- O as createCDPEmbeddedWallet,
17
- n as exportEvmAccount,
18
- m as getAccessToken,
19
- s as getCurrentUser,
10
+ P as APIError,
11
+ W as EIP1193ProviderError,
12
+ l as ErrorType,
13
+ D as HttpErrorType,
14
+ k as STANDARD_ERROR_CODES,
15
+ I as SendEvmTransactionWithEndUserAccountBodyNetwork,
16
+ R as createCDPEmbeddedWallet,
17
+ i as exportEvmAccount,
18
+ s as getAccessToken,
19
+ m as getCurrentUser,
20
+ a as getUserOperation,
20
21
  E as initialize,
21
- a as isSignedIn,
22
- p as onAuthStateChange,
22
+ p as isSignedIn,
23
+ g as onAuthStateChange,
23
24
  c as sendEvmTransaction,
24
- g as signEvmHash,
25
- d as signEvmMessage,
26
- v as signEvmTransaction,
27
- T as signEvmTypedData,
28
- A as signInWithEmail,
29
- f as signInWithSms,
30
- S as signOut,
31
- H as toViemAccount,
32
- h as verifyEmailOTP,
33
- u as verifySmsOTP
25
+ d as sendUserOperation,
26
+ v as signEvmHash,
27
+ T as signEvmMessage,
28
+ A as signEvmTransaction,
29
+ f as signEvmTypedData,
30
+ O as signInWithEmail,
31
+ S as signInWithSms,
32
+ h as signOut,
33
+ N as toViemAccount,
34
+ u as verifyEmailOTP,
35
+ x as verifySmsOTP
34
36
  };
@@ -1,4 +1,4 @@
1
- import n from "./index86.js";
1
+ import n from "./index84.js";
2
2
  function r(t) {
3
3
  return n(t) && typeof t.kty == "string";
4
4
  }
@@ -1,4 +1,4 @@
1
- import { JOSENotSupported as s } from "./index73.js";
1
+ import { JOSENotSupported as s } from "./index71.js";
2
2
  function n(e) {
3
3
  let a, r;
4
4
  switch (e.kty) {
@@ -1,12 +1,18 @@
1
- import { SendEvmTransactionWithEndUserAccountBodyNetwork as i } from "@coinbase/cdp-api-client";
1
+ import { SendEvmTransactionWithEndUserAccountBodyNetwork as a } from "@coinbase/cdp-api-client";
2
2
  const n = (e) => !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(n) : Object.keys(e).sort().reduce(
3
3
  (r, t) => (r[t] = n(e[t]), r),
4
4
  {}
5
- ), o = (e) => Object.values(i).includes(
5
+ ), o = (e) => Object.values(a).includes(
6
6
  e
7
7
  ), s = {
8
8
  "base-sepolia": 84532,
9
- base: 8453
9
+ base: 8453,
10
+ ethereum: 1,
11
+ "ethereum-sepolia": 11155111,
12
+ avalanche: 43114,
13
+ polygon: 137,
14
+ optimism: 10,
15
+ arbitrum: 42161
10
16
  }, c = Object.fromEntries(
11
17
  Object.entries(s).map(([e, r]) => [r, e])
12
18
  ), p = (e) => Object.values(s).includes(e);
@@ -1,6 +1,6 @@
1
- import { CompactSign as i } from "./index72.js";
2
- import { JWTInvalid as r } from "./index73.js";
3
- import { JWTClaimsBuilder as n } from "./index74.js";
1
+ import { CompactSign as i } from "./index70.js";
2
+ import { JWTInvalid as r } from "./index71.js";
3
+ import { JWTClaimsBuilder as n } from "./index72.js";
4
4
  class d {
5
5
  #s;
6
6
  #t;
@@ -1,89 +1,89 @@
1
- import { configureCdpApiClient as I, setAuthManager as l, initiateAuthentication as v, createEndUserEvmAccount as A, verifyEmailAuthentication as E, verifySmsAuthentication as k, signEvmHashWithEndUserAccount as S, signEvmTransactionWithEndUserAccount as M, sendEvmTransactionWithEndUserAccount as T, signEvmMessageWithEndUserAccount as U, signEvmTypedDataWithEndUserAccount as C, exportEndUserEvmAccount as j } from "@coinbase/cdp-api-client";
2
- import { AuthManager as P } from "./index6.js";
3
- import { toAuthState as d } from "./index7.js";
1
+ import { configureCdpApiClient as A, setAuthManager as v, initiateAuthentication as S, createEndUserEvmAccount as E, createEndUserEvmSmartAccount as g, verifyEmailAuthentication as k, verifySmsAuthentication as U, signEvmHashWithEndUserAccount as M, signEvmTransactionWithEndUserAccount as T, sendEvmTransactionWithEndUserAccount as j, signEvmMessageWithEndUserAccount as O, signEvmTypedDataWithEndUserAccount as P, sendUserOperationWithEndUserAccount as C, getUserOperationWithEndUserAccount as x, exportEndUserEvmAccount as H } from "@coinbase/cdp-api-client";
2
+ import { AuthManager as W } from "./index6.js";
3
+ import { toAuthState as m } from "./index7.js";
4
4
  import { withAuth as o } from "./index8.js";
5
- import { createExportKeyPair as x } from "./index9.js";
6
- import { decryptWithPrivateKey as b } from "./index10.js";
7
- import { MockAuthManager as K } from "./index11.js";
8
- import { mockUser as g } from "./index12.js";
9
- import { isChainSupportedForCDPSends as W } from "./index13.js";
10
- import { getConfig as n, setCoreAuthManager as m, getCoreAuthManager as s, setConfig as D } from "./index14.js";
5
+ import { createExportKeyPair as b } from "./index9.js";
6
+ import { decryptWithPrivateKey as K } from "./index10.js";
7
+ import { MockAuthManager as D } from "./index11.js";
8
+ import { mockUser as p } from "./index12.js";
9
+ import { isChainSupportedForCDPSends as z } from "./index13.js";
10
+ import { getConfig as t, setCoreAuthManager as h, getCoreAuthManager as s, setConfig as N } from "./index14.js";
11
11
  import "viem";
12
- import { serializeTransaction as p } from "./index15.js";
13
- const Q = async (e) => {
12
+ import { serializeTransaction as w } from "./index15.js";
13
+ const _ = async (e) => {
14
14
  if (!e.projectId)
15
15
  throw new Error("Project ID is required");
16
16
  let r;
17
17
  try {
18
- r = n().projectId !== e.projectId;
18
+ r = t().projectId !== e.projectId;
19
19
  } catch {
20
20
  r = !0;
21
21
  }
22
- if (D(e), n().useMock) {
23
- m(new K(n().projectId));
22
+ if (N(e), t().useMock) {
23
+ h(new D(t().projectId));
24
24
  return;
25
25
  }
26
- if (I({
27
- debugging: n().debugging,
28
- basePath: n().basePath
26
+ if (A({
27
+ debugging: t().debugging,
28
+ basePath: t().basePath
29
29
  }), r) {
30
- const t = new P(n().projectId);
31
- m(t), l(t);
30
+ const n = new W(t().projectId);
31
+ h(n), v(n);
32
32
  }
33
33
  await s().ensureInitialized();
34
- }, R = async (e) => h({
34
+ }, ee = async (e) => y({
35
35
  email: e.email,
36
36
  type: "email"
37
- }), X = async (e) => h({
37
+ }), te = async (e) => y({
38
38
  phoneNumber: e.phoneNumber,
39
39
  type: "sms"
40
- }), Y = async (e) => w(
40
+ }), re = async (e) => l(
41
41
  e,
42
42
  "Mock email OTP verified",
43
- (r, t) => E(r, t)
44
- ), Z = async (e) => w(
43
+ (r, n) => k(r, n)
44
+ ), ne = async (e) => l(
45
45
  e,
46
46
  "Mock SMS OTP verified",
47
- (r, t) => k(r, t)
48
- ), _ = async () => s().getUser(), ee = async () => s().isSignedIn(), te = async () => {
49
- if (n().useMock) {
47
+ (r, n) => U(r, n)
48
+ ), se = async () => s().getUser(), ae = async () => s().isSignedIn(), ce = async () => {
49
+ if (t().useMock) {
50
50
  await s().signOut();
51
51
  return;
52
52
  }
53
53
  if (!await s().isSignedIn())
54
54
  throw new Error("User not signed in");
55
55
  await s().signOut();
56
- }, ne = async () => s().getToken(), re = (e) => {
56
+ }, ie = async () => s().getToken(), oe = (e) => {
57
57
  s().addAuthStateChangeCallback(e);
58
- }, se = async (e) => n().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => ({
59
- signature: (await S(n().projectId, r.userId, {
58
+ }, ue = async (e) => t().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: n }) => ({
59
+ signature: (await M(t().projectId, r.userId, {
60
60
  hash: e.hash,
61
61
  address: e.evmAccount,
62
- walletSecretId: t
62
+ walletSecretId: n
63
63
  })).signature
64
- })), ae = async (e) => n().useMock ? { signedTransaction: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => {
65
- const i = p(e.transaction);
64
+ })), de = async (e) => t().useMock ? { signedTransaction: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: n }) => {
65
+ const i = w(e.transaction);
66
66
  return {
67
- signedTransaction: (await M(
68
- n().projectId,
67
+ signedTransaction: (await T(
68
+ t().projectId,
69
69
  r.userId,
70
70
  {
71
71
  transaction: i,
72
72
  address: e.evmAccount,
73
- walletSecretId: t
73
+ walletSecretId: n
74
74
  }
75
75
  )).signedTransaction
76
76
  };
77
- }), ie = async (e) => {
78
- if (!W(e.network))
77
+ }), me = async (e) => {
78
+ if (!z(e.network))
79
79
  throw new Error(`Chain ${e.network} is not supported by the CDP Apis`);
80
- if (n().useMock)
80
+ if (t().useMock)
81
81
  return { transactionHash: "0x0" };
82
- const r = p(e.transaction);
83
- return o(e, s(), async ({ user: t, walletSecretId: i }) => ({
84
- transactionHash: (await T(
85
- n().projectId,
86
- t.userId,
82
+ const r = w(e.transaction);
83
+ return o(e, s(), async ({ user: n, walletSecretId: i }) => ({
84
+ transactionHash: (await j(
85
+ t().projectId,
86
+ n.userId,
87
87
  {
88
88
  transaction: r,
89
89
  address: e.evmAccount,
@@ -92,99 +92,166 @@ const Q = async (e) => {
92
92
  }
93
93
  )).transactionHash
94
94
  }));
95
- }, ce = async (e) => n().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => ({
96
- signature: (await U(n().projectId, r.userId, {
95
+ }, ge = async (e) => t().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: n }) => ({
96
+ signature: (await O(t().projectId, r.userId, {
97
97
  message: e.message,
98
98
  address: e.evmAccount,
99
- walletSecretId: t
99
+ walletSecretId: n
100
100
  })).signature
101
- })), oe = async (e) => n().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: t }) => ({
102
- signature: (await C(n().projectId, r.userId, {
101
+ })), pe = async (e) => t().useMock ? { signature: "0x0" } : o(e, s(), async ({ user: r, walletSecretId: n }) => ({
102
+ signature: (await P(t().projectId, r.userId, {
103
103
  typedData: e.typedData,
104
104
  address: e.evmAccount,
105
- walletSecretId: t
105
+ walletSecretId: n
106
106
  })).signature
107
- })), ue = async (e) => {
108
- if (n().useMock)
107
+ })), he = async (e) => t().useMock ? {
108
+ userOperationHash: "0x1234567890123456789012345678901234567890123456789012345678901234"
109
+ } : o(e, s(), async ({ user: r, walletSecretId: n }) => ({
110
+ userOperationHash: (await C(
111
+ t().projectId,
112
+ r.userId,
113
+ e.evmSmartAccount,
114
+ {
115
+ network: e.network,
116
+ calls: e.calls.map((a) => ({
117
+ to: a.to,
118
+ value: String(a.value ?? 0n),
119
+ data: a.data ?? "0x"
120
+ })),
121
+ walletSecretId: n,
122
+ useCdpPaymaster: e.useCdpPaymaster ?? !1,
123
+ paymasterUrl: e.paymasterUrl
124
+ }
125
+ )).userOpHash
126
+ })), we = async (e) => t().useMock ? {
127
+ userOpHash: e.userOperationHash,
128
+ network: e.network,
129
+ calls: [
130
+ {
131
+ to: "0x1234567890123456789012345678901234567890",
132
+ value: "0",
133
+ data: "0x"
134
+ }
135
+ ],
136
+ status: "complete",
137
+ transactionHash: "0x9876543210987654321098765432109876543210987654321098765432109876",
138
+ receipts: []
139
+ } : o(e, s(), async ({ user: r }) => await x(
140
+ t().projectId,
141
+ r.userId,
142
+ e.evmSmartAccount,
143
+ e.userOperationHash
144
+ )), ye = async (e) => {
145
+ if (t().useMock)
109
146
  return {
110
147
  privateKey: "mock-private-key"
111
148
  };
112
- const r = await x();
113
- return o(e, s(), async ({ user: t, walletSecretId: i }) => {
114
- const a = await j(n().projectId, t.userId, {
149
+ const r = await b();
150
+ return o(e, s(), async ({ user: n, walletSecretId: i }) => {
151
+ const a = await H(t().projectId, n.userId, {
115
152
  address: e.evmAccount,
116
153
  walletSecretId: i,
117
154
  exportEncryptionKey: r.publicKeyBase64
118
155
  });
119
156
  return {
120
- privateKey: await b(
157
+ privateKey: await K(
121
158
  r.privateKey,
122
159
  a.encryptedPrivateKey
123
160
  )
124
161
  };
125
162
  });
126
- }, h = async (e) => {
127
- if (n().useMock)
163
+ }, y = async (e) => {
164
+ if (t().useMock)
128
165
  return {
129
166
  message: "Mock sign in initiated",
130
167
  flowId: "mock-flow-id"
131
168
  };
132
169
  if (await s().isSignedIn())
133
170
  throw new Error("User is already authenticated. Please sign out first.");
134
- const t = await v(n().projectId, e);
171
+ const n = await S(t().projectId, e);
135
172
  return {
136
- flowId: t.flowId,
137
- message: t.message
173
+ flowId: n.flowId,
174
+ message: n.message
138
175
  };
139
- }, w = async (e, r, t) => {
140
- if (n().useMock)
176
+ }, l = async (e, r, n) => {
177
+ if (t().useMock)
141
178
  return await s().setAuthState({
142
179
  accessToken: "mock-access-token",
143
180
  expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
144
- user: g
181
+ user: p
145
182
  }), {
146
183
  message: r,
147
- user: g,
184
+ user: p,
148
185
  isNewUser: !1
149
186
  };
150
187
  if (await s().isSignedIn())
151
188
  throw new Error("User is already authenticated. Please sign out first.");
152
- const a = await t(n().projectId, {
189
+ const a = await n(t().projectId, {
153
190
  flowId: e.flowId,
154
191
  otp: e.otp
155
192
  });
156
- let c = d(a.accessToken, a.validUntil, a.endUser);
193
+ let c = m(a.accessToken, a.validUntil, a.endUser);
157
194
  if (await s().setAuthState(c), !c.user.evmAccounts || c.user.evmAccounts.length === 0)
158
195
  try {
159
- const u = await s().getWalletSecretId(), f = await A(n().projectId, c.user.userId, {
196
+ const u = await s().getWalletSecretId();
197
+ let d = await E(t().projectId, c.user.userId, {
160
198
  walletSecretId: u
161
199
  });
162
- c = d(a.accessToken, a.validUntil, f), await s().setAuthState(c);
200
+ if (t().createAccountOnLogin === "evm-smart") {
201
+ const [I] = d.evmAccounts;
202
+ d = await g(
203
+ t().projectId,
204
+ c.user.userId,
205
+ {
206
+ owner: I,
207
+ enableSpendPermissions: !1
208
+ // Defaulting to false until the feature is ready.
209
+ }
210
+ );
211
+ }
212
+ c = m(a.accessToken, a.validUntil, d), await s().setAuthState(c);
163
213
  } catch (u) {
164
214
  throw new Error(`Failed to create EVM account: ${u}`);
165
215
  }
166
- const y = await s().getUser();
216
+ if (t().createAccountOnLogin === "evm-smart" && (!c.user.evmSmartAccounts || c.user.evmSmartAccounts.length === 0))
217
+ try {
218
+ const [u] = c.user.evmAccounts, d = await g(
219
+ t().projectId,
220
+ c.user.userId,
221
+ {
222
+ owner: u,
223
+ enableSpendPermissions: !1
224
+ // Defaulting to false until the feature is ready.
225
+ }
226
+ );
227
+ c = m(a.accessToken, a.validUntil, d), await s().setAuthState(c);
228
+ } catch (u) {
229
+ throw new Error(`Failed to create EVM Smart Account: ${u}`);
230
+ }
231
+ const f = await s().getUser();
167
232
  return {
168
233
  message: a.message,
169
- user: y,
234
+ user: f,
170
235
  isNewUser: a.isNewEndUser
171
236
  };
172
237
  };
173
238
  export {
174
- ue as exportEvmAccount,
175
- ne as getAccessToken,
176
- _ as getCurrentUser,
177
- Q as initialize,
178
- ee as isSignedIn,
179
- re as onAuthStateChange,
180
- ie as sendEvmTransaction,
181
- se as signEvmHash,
182
- ce as signEvmMessage,
183
- ae as signEvmTransaction,
184
- oe as signEvmTypedData,
185
- R as signInWithEmail,
186
- X as signInWithSms,
187
- te as signOut,
188
- Y as verifyEmailOTP,
189
- Z as verifySmsOTP
239
+ ye as exportEvmAccount,
240
+ ie as getAccessToken,
241
+ se as getCurrentUser,
242
+ we as getUserOperation,
243
+ _ as initialize,
244
+ ae as isSignedIn,
245
+ oe as onAuthStateChange,
246
+ me as sendEvmTransaction,
247
+ he as sendUserOperation,
248
+ ue as signEvmHash,
249
+ ge as signEvmMessage,
250
+ de as signEvmTransaction,
251
+ pe as signEvmTypedData,
252
+ ee as signInWithEmail,
253
+ te as signInWithSms,
254
+ ce as signOut,
255
+ re as verifyEmailOTP,
256
+ ne as verifySmsOTP
190
257
  };
@@ -1,4 +1,4 @@
1
- import { chainConfig as a } from "./index81.js";
1
+ import { chainConfig as a } from "./index85.js";
2
2
  import { defineChain as t } from "./index25.js";
3
3
  const e = 11155111, r = /* @__PURE__ */ t({
4
4
  ...a,
@@ -1,4 +1,4 @@
1
- import { version as o } from "./index70.js";
1
+ import { version as o } from "./index73.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 "./index71.js";
1
+ import { NegativeOffsetError as o, PositionOutOfBoundsError as e, RecursiveReadLimitExceededError as n } from "./index74.js";
2
2
  const h = {
3
3
  bytes: new Uint8Array(),
4
4
  dataView: new DataView(new ArrayBuffer(0)),
@@ -1,16 +1,17 @@
1
1
  import "@coinbase/cdp-api-client";
2
- const c = (s, u, e) => {
3
- const n = new Date(u).getTime(), r = {
2
+ const r = (u, c, e) => {
3
+ const s = new Date(c).getTime(), m = {
4
4
  userId: e.userId,
5
5
  evmAccounts: e.evmAccounts?.map((t) => t) ?? [],
6
+ evmSmartAccounts: e.evmSmartAccounts?.map((t) => t) ?? [],
6
7
  authenticationMethods: e.authenticationMethods.reduce((t, o) => (t[o.type] = o, t), {})
7
8
  };
8
9
  return {
9
- accessToken: s,
10
- expiresAt: n,
11
- user: r
10
+ accessToken: u,
11
+ expiresAt: s,
12
+ user: m
12
13
  };
13
14
  };
14
15
  export {
15
- c as toAuthState
16
+ r as toAuthState
16
17
  };