@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.
- package/README.md +75 -1
- package/dist/esm/index.js +29 -27
- package/dist/esm/index15.js +8 -8
- package/dist/esm/index16.js +2 -2
- package/dist/esm/index2.js +154 -87
- package/dist/esm/index20.js +1 -1
- package/dist/esm/index25.js +8 -12
- package/dist/esm/index26.js +17 -11
- package/dist/esm/index27.js +45 -8
- package/dist/esm/index28.js +13 -17
- package/dist/esm/index29.js +50 -40
- package/dist/esm/index30.js +6 -13
- package/dist/esm/index31.js +20 -54
- package/dist/esm/index32.js +11 -6
- package/dist/esm/index33.js +3 -21
- package/dist/esm/index34.js +3 -3
- package/dist/esm/index35.js +34 -3
- package/dist/esm/index36.js +10 -32
- package/dist/esm/index37.js +4 -12
- package/dist/esm/index38.js +28 -4
- package/dist/esm/index39.js +6 -28
- package/dist/esm/index40.js +24 -6
- package/dist/esm/index41.js +16 -24
- package/dist/esm/index42.js +54 -16
- package/dist/esm/index43.js +22 -53
- package/dist/esm/index44.js +11 -23
- package/dist/esm/index45.js +26 -10
- package/dist/esm/index46.js +41 -26
- package/dist/esm/index47.js +54 -41
- package/dist/esm/index48.js +126 -54
- package/dist/esm/index49.js +11 -126
- package/dist/esm/index50.js +101 -9
- package/dist/esm/index51.js +6 -104
- package/dist/esm/index52.js +3 -7
- package/dist/esm/index53.js +15 -3
- package/dist/esm/index54.js +42 -14
- package/dist/esm/index55.js +74 -38
- package/dist/esm/index56.js +2 -79
- package/dist/esm/index57.js +2 -2
- package/dist/esm/index58.js +13 -2
- package/dist/esm/index59.js +2 -2
- package/dist/esm/index60.js +1 -1
- package/dist/esm/index61.js +1 -1
- package/dist/esm/index62.js +2 -2
- package/dist/esm/index63.js +2 -2
- package/dist/esm/index64.js +1 -1
- package/dist/esm/index65.js +1 -1
- package/dist/esm/index66.js +3 -3
- package/dist/esm/index7.js +7 -6
- package/dist/esm/index73.js +2 -104
- package/dist/esm/index74.js +17 -75
- package/dist/esm/index75.js +20 -80
- package/dist/esm/index76.js +80 -2
- package/dist/esm/index77.js +100 -17
- package/dist/esm/index78.js +31 -18
- package/dist/esm/index79.js +6 -32
- package/dist/esm/index8.js +10 -8
- package/dist/esm/index80.js +78 -6
- package/dist/esm/index89.js +4 -4
- package/dist/esm/index90.js +5 -5
- package/dist/types/index.d.ts +33 -0
- 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
|
|
2
|
-
import { APIError as
|
|
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
|
|
5
|
-
import { EIP1193ProviderError as
|
|
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
|
|
8
|
+
import { toViemAccount as N } from "./index5.js";
|
|
9
9
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
|
|
22
|
+
p as isSignedIn,
|
|
23
|
+
g as onAuthStateChange,
|
|
23
24
|
c as sendEvmTransaction,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
S as
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
u as
|
|
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
|
};
|
package/dist/esm/index15.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { InvalidLegacyVError as H } from "./
|
|
2
|
-
import { serializeAuthorizationList as g } from "./
|
|
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 "./
|
|
8
|
-
import { trim as T } from "./
|
|
9
|
-
import { numberToHex as o, bytesToHex as w } from "./
|
|
10
|
-
import { toRlp as b } from "./
|
|
11
|
-
import { assertTransactionEIP1559 as S, assertTransactionEIP2930 as _, assertTransactionEIP4844 as R, assertTransactionEIP7702 as Y, assertTransactionLegacy as j } from "./
|
|
12
|
-
import { getTransactionType as q } from "./
|
|
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);
|
package/dist/esm/index16.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InvalidAddressError as s } from "./
|
|
2
|
-
import { isAddress as a } from "./
|
|
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 }))
|
package/dist/esm/index2.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import { configureCdpApiClient as
|
|
2
|
-
import { AuthManager as
|
|
3
|
-
import { toAuthState as
|
|
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
|
|
6
|
-
import { decryptWithPrivateKey as
|
|
7
|
-
import { MockAuthManager as
|
|
8
|
-
import { mockUser as
|
|
9
|
-
import { isChainSupportedForCDPSends as
|
|
10
|
-
import { getConfig as
|
|
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
|
|
13
|
-
const
|
|
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 =
|
|
18
|
+
r = t().projectId !== e.projectId;
|
|
19
19
|
} catch {
|
|
20
20
|
r = !0;
|
|
21
21
|
}
|
|
22
|
-
if (
|
|
23
|
-
|
|
22
|
+
if (N(e), t().useMock) {
|
|
23
|
+
h(new D(t().projectId));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
debugging:
|
|
28
|
-
basePath:
|
|
26
|
+
if (A({
|
|
27
|
+
debugging: t().debugging,
|
|
28
|
+
basePath: t().basePath
|
|
29
29
|
}), r) {
|
|
30
|
-
const
|
|
31
|
-
|
|
30
|
+
const n = new W(t().projectId);
|
|
31
|
+
h(n), v(n);
|
|
32
32
|
}
|
|
33
33
|
await s().ensureInitialized();
|
|
34
|
-
},
|
|
34
|
+
}, ee = async (e) => y({
|
|
35
35
|
email: e.email,
|
|
36
36
|
type: "email"
|
|
37
|
-
}),
|
|
37
|
+
}), te = async (e) => y({
|
|
38
38
|
phoneNumber: e.phoneNumber,
|
|
39
39
|
type: "sms"
|
|
40
|
-
}),
|
|
40
|
+
}), re = async (e) => l(
|
|
41
41
|
e,
|
|
42
42
|
"Mock email OTP verified",
|
|
43
|
-
(r,
|
|
44
|
-
),
|
|
43
|
+
(r, n) => k(r, n)
|
|
44
|
+
), ne = async (e) => l(
|
|
45
45
|
e,
|
|
46
46
|
"Mock SMS OTP verified",
|
|
47
|
-
(r,
|
|
48
|
-
),
|
|
49
|
-
if (
|
|
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
|
-
},
|
|
56
|
+
}, ie = async () => s().getToken(), oe = (e) => {
|
|
57
57
|
s().addAuthStateChangeCallback(e);
|
|
58
|
-
},
|
|
59
|
-
signature: (await
|
|
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:
|
|
62
|
+
walletSecretId: n
|
|
63
63
|
})).signature
|
|
64
|
-
})),
|
|
65
|
-
const i =
|
|
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
|
|
68
|
-
|
|
67
|
+
signedTransaction: (await T(
|
|
68
|
+
t().projectId,
|
|
69
69
|
r.userId,
|
|
70
70
|
{
|
|
71
71
|
transaction: i,
|
|
72
72
|
address: e.evmAccount,
|
|
73
|
-
walletSecretId:
|
|
73
|
+
walletSecretId: n
|
|
74
74
|
}
|
|
75
75
|
)).signedTransaction
|
|
76
76
|
};
|
|
77
|
-
}),
|
|
78
|
-
if (!
|
|
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 (
|
|
80
|
+
if (t().useMock)
|
|
81
81
|
return { transactionHash: "0x0" };
|
|
82
|
-
const r =
|
|
83
|
-
return o(e, s(), async ({ user:
|
|
84
|
-
transactionHash: (await
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
},
|
|
96
|
-
signature: (await
|
|
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:
|
|
99
|
+
walletSecretId: n
|
|
100
100
|
})).signature
|
|
101
|
-
})),
|
|
102
|
-
signature: (await
|
|
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:
|
|
105
|
+
walletSecretId: n
|
|
106
106
|
})).signature
|
|
107
|
-
})),
|
|
108
|
-
|
|
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
|
|
113
|
-
return o(e, s(), async ({ user:
|
|
114
|
-
const a = await
|
|
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
|
|
157
|
+
privateKey: await K(
|
|
121
158
|
r.privateKey,
|
|
122
159
|
a.encryptedPrivateKey
|
|
123
160
|
)
|
|
124
161
|
};
|
|
125
162
|
});
|
|
126
|
-
},
|
|
127
|
-
if (
|
|
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
|
|
171
|
+
const n = await S(t().projectId, e);
|
|
135
172
|
return {
|
|
136
|
-
flowId:
|
|
137
|
-
message:
|
|
173
|
+
flowId: n.flowId,
|
|
174
|
+
message: n.message
|
|
138
175
|
};
|
|
139
|
-
},
|
|
140
|
-
if (
|
|
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:
|
|
181
|
+
user: p
|
|
145
182
|
}), {
|
|
146
183
|
message: r,
|
|
147
|
-
user:
|
|
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(
|
|
189
|
+
const a = await n(t().projectId, {
|
|
153
190
|
flowId: e.flowId,
|
|
154
191
|
otp: e.otp
|
|
155
192
|
});
|
|
156
|
-
let c =
|
|
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()
|
|
196
|
+
const u = await s().getWalletSecretId();
|
|
197
|
+
let d = await E(t().projectId, c.user.userId, {
|
|
160
198
|
walletSecretId: u
|
|
161
199
|
});
|
|
162
|
-
|
|
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
|
-
|
|
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:
|
|
234
|
+
user: f,
|
|
170
235
|
isNewUser: a.isNewEndUser
|
|
171
236
|
};
|
|
172
237
|
};
|
|
173
238
|
export {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
};
|
package/dist/esm/index20.js
CHANGED
package/dist/esm/index25.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
+
n as defineChain
|
|
15
11
|
};
|
package/dist/esm/index26.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
13
|
-
r as isAddressCache
|
|
19
|
+
f as serializeAuthorizationList
|
|
14
20
|
};
|
package/dist/esm/index27.js
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
43
|
+
z as boolToHex,
|
|
44
|
+
m as bytesToHex,
|
|
45
|
+
y as numberToHex,
|
|
46
|
+
$ as stringToHex,
|
|
47
|
+
B as toHex
|
|
11
48
|
};
|