@coinbase/cdp-core 0.0.20 → 0.0.22

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 (62) hide show
  1. package/README.md +75 -1
  2. package/dist/esm/index.js +29 -27
  3. package/dist/esm/index15.js +8 -8
  4. package/dist/esm/index16.js +2 -2
  5. package/dist/esm/index2.js +154 -87
  6. package/dist/esm/index20.js +1 -1
  7. package/dist/esm/index25.js +8 -12
  8. package/dist/esm/index26.js +17 -11
  9. package/dist/esm/index27.js +45 -8
  10. package/dist/esm/index28.js +13 -17
  11. package/dist/esm/index29.js +50 -40
  12. package/dist/esm/index30.js +6 -13
  13. package/dist/esm/index31.js +20 -54
  14. package/dist/esm/index32.js +11 -6
  15. package/dist/esm/index33.js +3 -21
  16. package/dist/esm/index34.js +3 -3
  17. package/dist/esm/index35.js +34 -3
  18. package/dist/esm/index36.js +10 -32
  19. package/dist/esm/index37.js +4 -12
  20. package/dist/esm/index38.js +28 -4
  21. package/dist/esm/index39.js +6 -28
  22. package/dist/esm/index40.js +24 -6
  23. package/dist/esm/index41.js +16 -24
  24. package/dist/esm/index42.js +54 -16
  25. package/dist/esm/index43.js +22 -53
  26. package/dist/esm/index44.js +11 -23
  27. package/dist/esm/index45.js +26 -10
  28. package/dist/esm/index46.js +41 -26
  29. package/dist/esm/index47.js +54 -41
  30. package/dist/esm/index48.js +126 -54
  31. package/dist/esm/index49.js +11 -126
  32. package/dist/esm/index50.js +101 -9
  33. package/dist/esm/index51.js +6 -104
  34. package/dist/esm/index52.js +3 -7
  35. package/dist/esm/index53.js +15 -3
  36. package/dist/esm/index54.js +42 -14
  37. package/dist/esm/index55.js +74 -38
  38. package/dist/esm/index56.js +2 -79
  39. package/dist/esm/index57.js +2 -2
  40. package/dist/esm/index58.js +13 -2
  41. package/dist/esm/index59.js +2 -2
  42. package/dist/esm/index60.js +1 -1
  43. package/dist/esm/index61.js +1 -1
  44. package/dist/esm/index62.js +2 -2
  45. package/dist/esm/index63.js +2 -2
  46. package/dist/esm/index64.js +1 -1
  47. package/dist/esm/index65.js +1 -1
  48. package/dist/esm/index66.js +3 -3
  49. package/dist/esm/index7.js +7 -6
  50. package/dist/esm/index73.js +2 -104
  51. package/dist/esm/index74.js +17 -75
  52. package/dist/esm/index75.js +20 -80
  53. package/dist/esm/index76.js +80 -2
  54. package/dist/esm/index77.js +100 -17
  55. package/dist/esm/index78.js +31 -18
  56. package/dist/esm/index79.js +6 -32
  57. package/dist/esm/index8.js +10 -8
  58. package/dist/esm/index80.js +78 -6
  59. package/dist/esm/index89.js +4 -4
  60. package/dist/esm/index90.js +5 -5
  61. package/dist/types/index.d.ts +33 -0
  62. package/package.json +3 -3
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;
@@ -163,6 +182,61 @@ const hash = await client.sendRawTransaction({
163
182
  });
164
183
  ```
165
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
+
166
240
  ### Sign Messages and Typed Data
167
241
 
168
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,15 +1,15 @@
1
- import { InvalidLegacyVError as H } from "./index55.js";
2
- import { serializeAuthorizationList as g } from "./index28.js";
1
+ import { InvalidLegacyVError as H } from "./index54.js";
2
+ import { serializeAuthorizationList as g } from "./index26.js";
3
3
  import { blobsToCommitments as B } from "./index62.js";
4
4
  import { blobsToProofs as V } from "./index63.js";
5
5
  import { commitmentsToVersionedHashes as C } from "./index64.js";
6
6
  import { toBlobSidecars as k } from "./index65.js";
7
- import { concatHex as h } from "./index34.js";
8
- import { trim as T } from "./index40.js";
9
- import { numberToHex as o, bytesToHex as w } from "./index29.js";
10
- import { toRlp as b } from "./index47.js";
11
- import { assertTransactionEIP1559 as S, assertTransactionEIP2930 as _, assertTransactionEIP4844 as R, assertTransactionEIP7702 as Y, assertTransactionLegacy as j } from "./index56.js";
12
- import { getTransactionType as q } from "./index54.js";
7
+ import { concatHex as h } from "./index33.js";
8
+ import { trim as T } from "./index39.js";
9
+ import { numberToHex as o, bytesToHex as w } from "./index27.js";
10
+ import { toRlp as b } from "./index46.js";
11
+ import { assertTransactionEIP1559 as S, assertTransactionEIP2930 as _, assertTransactionEIP4844 as R, assertTransactionEIP7702 as Y, assertTransactionLegacy as j } from "./index55.js";
12
+ import { getTransactionType as q } from "./index53.js";
13
13
  import { serializeAccessList as v } from "./index66.js";
14
14
  function te(e, r) {
15
15
  const i = q(e);
@@ -1,5 +1,5 @@
1
- import { InvalidAddressError as s } from "./index25.js";
2
- import { isAddress as a } from "./index26.js";
1
+ import { InvalidAddressError as s } from "./index58.js";
2
+ import { isAddress as a } from "./index32.js";
3
3
  function r(n) {
4
4
  if (typeof n == "string") {
5
5
  if (!a(n, { strict: !1 }))
@@ -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,5 +1,5 @@
1
1
  import { chainConfig as a } from "./index81.js";
2
- import { defineChain as t } from "./index27.js";
2
+ import { defineChain as t } from "./index25.js";
3
3
  const e = 11155111, r = /* @__PURE__ */ t({
4
4
  ...a,
5
5
  id: 84532,
@@ -1,15 +1,11 @@
1
- import { BaseError as r } from "./index48.js";
2
- class d extends r {
3
- constructor({ address: s }) {
4
- super(`Address "${s}" is invalid.`, {
5
- metaMessages: [
6
- "- Address must be a hex value of 20 bytes (40 hex characters).",
7
- "- Address must match its checksum counterpart."
8
- ],
9
- name: "InvalidAddressError"
10
- });
11
- }
1
+ function n(e) {
2
+ return {
3
+ formatters: void 0,
4
+ fees: void 0,
5
+ serializers: void 0,
6
+ ...e
7
+ };
12
8
  }
13
9
  export {
14
- d as InvalidAddressError
10
+ n as defineChain
15
11
  };
@@ -1,14 +1,20 @@
1
- import { LruMap as u } from "./index33.js";
2
- import { checksumAddress as c } from "./index30.js";
3
- const i = /^0x[a-fA-F0-9]{40}$/, r = /* @__PURE__ */ new u(8192);
4
- function h(t, s) {
5
- const { strict: n = !0 } = s ?? {}, e = `${t}.${n}`;
6
- if (r.has(e))
7
- return r.get(e);
8
- const o = i.test(t) ? t.toLowerCase() === t ? !0 : n ? c(t) === t : !0 : !1;
9
- return r.set(e, o), o;
1
+ import { toHex as i } from "./index27.js";
2
+ import { toYParitySignatureArray as c } from "./index15.js";
3
+ function f(r) {
4
+ if (!r || r.length === 0)
5
+ return [];
6
+ const t = [];
7
+ for (const o of r) {
8
+ const { chainId: n, nonce: e, ...s } = o, a = o.address;
9
+ t.push([
10
+ n ? i(n) : "0x",
11
+ a,
12
+ e ? i(e) : "0x",
13
+ ...c({}, s)
14
+ ]);
15
+ }
16
+ return t;
10
17
  }
11
18
  export {
12
- h as isAddress,
13
- r as isAddressCache
19
+ f as serializeAuthorizationList
14
20
  };
@@ -1,11 +1,48 @@
1
- function n(e) {
2
- return {
3
- formatters: void 0,
4
- fees: void 0,
5
- serializers: void 0,
6
- ...e
7
- };
1
+ import { IntegerOutOfRangeError as x } from "./index49.js";
2
+ import { pad as s } from "./index35.js";
3
+ import { assertSize as c } from "./index43.js";
4
+ const b = /* @__PURE__ */ Array.from({ length: 256 }, (n, e) => e.toString(16).padStart(2, "0"));
5
+ function B(n, e = {}) {
6
+ return typeof n == "number" || typeof n == "bigint" ? y(n, e) : typeof n == "string" ? $(n, e) : typeof n == "boolean" ? z(n, e) : m(n, e);
7
+ }
8
+ function z(n, e = {}) {
9
+ const t = `0x${Number(n)}`;
10
+ return typeof e.size == "number" ? (c(t, { size: e.size }), s(t, { size: e.size })) : t;
11
+ }
12
+ function m(n, e = {}) {
13
+ let t = "";
14
+ for (let i = 0; i < n.length; i++)
15
+ t += b[n[i]];
16
+ const r = `0x${t}`;
17
+ return typeof e.size == "number" ? (c(r, { size: e.size }), s(r, { dir: "right", size: e.size })) : r;
18
+ }
19
+ function y(n, e = {}) {
20
+ const { signed: t, size: r } = e, i = BigInt(n);
21
+ let o;
22
+ r ? t ? o = (1n << BigInt(r) * 8n - 1n) - 1n : o = 2n ** (BigInt(r) * 8n) - 1n : typeof n == "number" && (o = BigInt(Number.MAX_SAFE_INTEGER));
23
+ const g = typeof o == "bigint" && t ? -o - 1n : 0;
24
+ if (o && i > o || i < g) {
25
+ const f = typeof n == "bigint" ? "n" : "";
26
+ throw new x({
27
+ max: o ? `${o}${f}` : void 0,
28
+ min: `${g}${f}`,
29
+ signed: t,
30
+ size: r,
31
+ value: `${n}${f}`
32
+ });
33
+ }
34
+ const u = `0x${(t && i < 0 ? (1n << BigInt(r * 8)) + BigInt(i) : i).toString(16)}`;
35
+ return r ? s(u, { size: r }) : u;
36
+ }
37
+ const d = /* @__PURE__ */ new TextEncoder();
38
+ function $(n, e = {}) {
39
+ const t = d.encode(n);
40
+ return m(t, e);
8
41
  }
9
42
  export {
10
- n as defineChain
43
+ z as boolToHex,
44
+ m as bytesToHex,
45
+ y as numberToHex,
46
+ $ as stringToHex,
47
+ B as toHex
11
48
  };