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