@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 +88 -6
- package/dist/esm/index.js +29 -27
- package/dist/esm/index103.js +1 -1
- package/dist/esm/index104.js +1 -1
- package/dist/esm/index13.js +9 -3
- package/dist/esm/index17.js +3 -3
- package/dist/esm/index2.js +154 -87
- package/dist/esm/index24.js +1 -1
- package/dist/esm/index47.js +1 -1
- package/dist/esm/index48.js +1 -1
- package/dist/esm/index7.js +7 -6
- package/dist/esm/index70.js +17 -2
- package/dist/esm/index71.js +19 -17
- package/dist/esm/index72.js +47 -13
- package/dist/esm/index73.js +2 -23
- package/dist/esm/index74.js +17 -47
- package/dist/esm/index77.js +1 -1
- package/dist/esm/index8.js +10 -8
- package/dist/esm/index80.js +50 -74
- package/dist/esm/index81.js +11 -10
- package/dist/esm/index82.js +2 -55
- package/dist/esm/index83.js +45 -11
- package/dist/esm/index84.js +14 -2
- package/dist/esm/index85.js +9 -44
- package/dist/esm/index86.js +78 -13
- package/dist/esm/index88.js +20 -12
- package/dist/esm/index89.js +9 -35
- package/dist/esm/index90.js +19 -41
- package/dist/esm/index91.js +93 -20
- package/dist/esm/index92.js +20 -9
- package/dist/esm/index93.js +114 -16
- package/dist/esm/index94.js +11 -92
- package/dist/esm/index95.js +35 -20
- package/dist/esm/index96.js +41 -117
- package/dist/esm/index98.js +1 -1
- package/dist/types/index.d.ts +39 -2
- package/package.json +4 -4
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
|
|
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
|
|
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 {
|
|
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:
|
|
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:
|
|
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
|
|
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/index103.js
CHANGED
package/dist/esm/index104.js
CHANGED
package/dist/esm/index13.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { SendEvmTransactionWithEndUserAccountBodyNetwork as
|
|
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(
|
|
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);
|
package/dist/esm/index17.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CompactSign as i } from "./
|
|
2
|
-
import { JWTInvalid as r } from "./
|
|
3
|
-
import { JWTClaimsBuilder as n } from "./
|
|
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;
|
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/index24.js
CHANGED
package/dist/esm/index47.js
CHANGED
package/dist/esm/index48.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NegativeOffsetError as o, PositionOutOfBoundsError as e, RecursiveReadLimitExceededError as n } from "./
|
|
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)),
|
package/dist/esm/index7.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import "@coinbase/cdp-api-client";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
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:
|
|
10
|
-
expiresAt:
|
|
11
|
-
user:
|
|
10
|
+
accessToken: u,
|
|
11
|
+
expiresAt: s,
|
|
12
|
+
user: m
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
r as toAuthState
|
|
16
17
|
};
|