@coinbase/cdp-hooks 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,11 +3,13 @@ Built on top of `@coinbase/cdp-core`, it offers a React-friendly interface for e
3
3
  and embedded wallet operations.
4
4
 
5
5
  ## Quickstart
6
- This guide will help you get started with @coinbase/cdp-hooks. You'll learn how to install the package, set up the provider, and use the hooks in a variety of ways.
6
+ This guide will help you get started with @coinbase/cdp-hooks. You'll learn how to install the package, set up the provider, and use the hooks in both web and React Native applications.
7
7
 
8
8
  ### Installation
9
9
 
10
- First, add the package to your project using your preferred package manager.
10
+ #### Web Applications
11
+
12
+ For web applications, add the package to your project using your preferred package manager:
11
13
 
12
14
  ```bash
13
15
  # With npm
@@ -20,6 +22,55 @@ pnpm add @coinbase/cdp-core @coinbase/cdp-hooks
20
22
  yarn add @coinbase/cdp-core @coinbase/cdp-hooks
21
23
  ```
22
24
 
25
+ #### React Native Applications
26
+
27
+ For React Native applications, you'll need additional crypto polyfills and dependencies:
28
+
29
+ ```bash
30
+ # Core packages
31
+ npm install @coinbase/cdp-core @coinbase/cdp-hooks
32
+
33
+ # Install this polyfill with expo for better compatibility
34
+ npx expo install react-native-quick-crypto
35
+
36
+ # Required crypto polyfills for React Native
37
+ npm install react-native-get-random-values @ungap/structured-clone
38
+
39
+ # AsyncStorage for React Native storage
40
+ npm install @react-native-async-storage/async-storage
41
+ ```
42
+
43
+ **React Native Setup Code**
44
+
45
+ You'll need to initialize the crypto polyfills before importing your app. Create or update your entry point file (typically `index.js` or `index.ts`):
46
+
47
+ ```typescript
48
+ import structuredClone from "@ungap/structured-clone";
49
+ import { install } from "react-native-quick-crypto";
50
+ import "react-native-get-random-values";
51
+
52
+ // Install crypto polyfills
53
+ if (!("structuredClone" in globalThis)) {
54
+ globalThis.structuredClone = structuredClone as any;
55
+ }
56
+
57
+ install(); // Install react-native-quick-crypto
58
+
59
+ // Import your app after polyfills are installed
60
+ import App from "./App";
61
+
62
+ // Register your app component
63
+ import { registerRootComponent } from "expo"; // For Expo apps
64
+ registerRootComponent(App);
65
+ ```
66
+
67
+ **Why these dependencies?**
68
+
69
+ - `react-native-quick-crypto`: Provides Web Crypto API compatibility for asymmetric key generation (ECDSA, RSA) required for JWT signing and encryption
70
+ - `react-native-get-random-values`: Provides secure random number generation via `crypto.getRandomValues()`
71
+ - `@ungap/structured-clone`: Polyfills `structuredClone` for object cloning compatibility
72
+ - `@react-native-async-storage/async-storage`: Provides persistent storage for auth tokens and secrets
73
+
23
74
  ### Gather your CDP Project Information
24
75
 
25
76
  1. Sign in or create an account on the [CDP Portal](https://portal.cdp.coinbase.com)
@@ -38,9 +89,12 @@ in CDP Portal, and click Add origin to include your local app
38
89
  Next, you need to wrap your application with the CDPHooksProvider, which provides the necessary context for
39
90
  hooks to work correctly.
40
91
 
92
+ #### Web Applications
93
+
41
94
  Update your main application file (e.g., main.tsx) to include the provider:
42
95
 
43
96
  ```tsx lines
97
+ import React from "react";
44
98
  import { CDPHooksProvider } from "@coinbase/cdp-hooks";
45
99
  import { App } from './App'; // Your main App component
46
100
 
@@ -58,6 +112,26 @@ function App() {
58
112
  }
59
113
  ```
60
114
 
115
+ #### React Native Applications
116
+
117
+ For React Native, the setup is identical.
118
+
119
+ ```tsx lines
120
+ import React from "react";
121
+ import { CDPHooksProvider } from "@coinbase/cdp-hooks";
122
+ import { App } from "./App";
123
+
124
+ export default function App() {
125
+ return (
126
+ <CDPHooksProvider config={{
127
+ projectId: "your-project-id",
128
+ }}>
129
+ <App />
130
+ </CDPHooksProvider>
131
+ );
132
+ }
133
+ ```
134
+
61
135
  #### Smart Account Configuration
62
136
 
63
137
  You can configure the provider to automatically create Smart Accounts for new users:
@@ -85,7 +159,7 @@ End user authentication proceeds in two steps:
85
159
  1. The user inputs their email address to initiate the authentication flow, which will send the user a One Time Password (OTP) and return a `flowId`
86
160
  2. The user submits the six-digit OTP and `flowId`, after which the user will be authenticated, returning a User object.
87
161
 
88
- The following code demonstrates this flow:
162
+ #### Web Applications
89
163
 
90
164
  ```tsx lines
91
165
  import { useSignInWithEmail, useVerifyEmailOTP } from "@coinbase/cdp-hooks";
@@ -121,6 +195,124 @@ function SignIn() {
121
195
  }
122
196
  ```
123
197
 
198
+ #### React Native Applications
199
+
200
+ For React Native, you'll use native UI components and handle the sign-in flow similarly:
201
+
202
+ ```tsx lines
203
+ import React, { useState } from "react";
204
+ import { View, Text, TextInput, TouchableOpacity, Alert } from "react-native";
205
+ import { useSignInWithEmail, useVerifyEmailOTP } from "@coinbase/cdp-hooks";
206
+
207
+ function SignInScreen() {
208
+ const { signInWithEmail } = useSignInWithEmail();
209
+ const { verifyEmailOTP } = useVerifyEmailOTP();
210
+ const [email, setEmail] = useState("");
211
+ const [otp, setOtp] = useState("");
212
+ const [flowId, setFlowId] = useState("");
213
+ const [isLoading, setIsLoading] = useState(false);
214
+
215
+ const handleSignIn = async () => {
216
+ if (!email) {
217
+ Alert.alert("Error", "Please enter an email address");
218
+ return;
219
+ }
220
+
221
+ setIsLoading(true);
222
+ try {
223
+ const result = await signInWithEmail({ email });
224
+ setFlowId(result.flowId);
225
+ Alert.alert("Success", "OTP sent to your email!");
226
+ } catch (error) {
227
+ Alert.alert("Error", error instanceof Error ? error.message : "Failed to sign in");
228
+ } finally {
229
+ setIsLoading(false);
230
+ }
231
+ };
232
+
233
+ const handleVerifyOTP = async () => {
234
+ if (!otp || !flowId) {
235
+ Alert.alert("Error", "Please enter the OTP");
236
+ return;
237
+ }
238
+
239
+ setIsLoading(true);
240
+ try {
241
+ const { user } = await verifyEmailOTP({ flowId, otp });
242
+ Alert.alert("Success", "Successfully signed in!");
243
+ console.log("Signed in user:", user);
244
+ } catch (error) {
245
+ Alert.alert("Error", error instanceof Error ? error.message : "Failed to verify OTP");
246
+ } finally {
247
+ setIsLoading(false);
248
+ }
249
+ };
250
+
251
+ return (
252
+ <View style={{ padding: 20 }}>
253
+ <Text>Email:</Text>
254
+ <TextInput
255
+ value={email}
256
+ onChangeText={setEmail}
257
+ placeholder="Enter your email"
258
+ keyboardType="email-address"
259
+ autoCapitalize="none"
260
+ editable={!isLoading}
261
+ style={{ borderWidth: 1, borderColor: "#ddd", padding: 12, marginBottom: 16 }}
262
+ />
263
+
264
+ <TouchableOpacity
265
+ onPress={handleSignIn}
266
+ disabled={isLoading}
267
+ style={{
268
+ backgroundColor: "#007AFF",
269
+ padding: 15,
270
+ borderRadius: 8,
271
+ alignItems: "center",
272
+ marginBottom: 12,
273
+ opacity: isLoading ? 0.6 : 1,
274
+ }}
275
+ >
276
+ <Text style={{ color: "white", fontSize: 16, fontWeight: "600" }}>
277
+ {isLoading ? "Sending..." : "Sign In with Email"}
278
+ </Text>
279
+ </TouchableOpacity>
280
+
281
+ {flowId && (
282
+ <>
283
+ <Text>Enter OTP from email:</Text>
284
+ <TextInput
285
+ value={otp}
286
+ onChangeText={setOtp}
287
+ placeholder="Enter 6-digit OTP"
288
+ keyboardType="number-pad"
289
+ maxLength={6}
290
+ editable={!isLoading}
291
+ style={{ borderWidth: 1, borderColor: "#ddd", padding: 12, marginBottom: 16 }}
292
+ />
293
+
294
+ <TouchableOpacity
295
+ onPress={handleVerifyOTP}
296
+ disabled={isLoading}
297
+ style={{
298
+ backgroundColor: "#007AFF",
299
+ padding: 15,
300
+ borderRadius: 8,
301
+ alignItems: "center",
302
+ opacity: isLoading ? 0.6 : 1,
303
+ }}
304
+ >
305
+ <Text style={{ color: "white", fontSize: 16, fontWeight: "600" }}>
306
+ {isLoading ? "Verifying..." : "Verify OTP"}
307
+ </Text>
308
+ </TouchableOpacity>
309
+ </>
310
+ )}
311
+ </View>
312
+ );
313
+ }
314
+ ```
315
+
124
316
  ### View User Information
125
317
 
126
318
  Once the end user has signed in, you can display their information in your application:
@@ -1,7 +1,7 @@
1
1
  import { TimeoutError as m, HttpRequestError as i } from "./index13.js";
2
2
  import { withTimeout as j } from "./index177.js";
3
3
  import { stringify as c } from "./index103.js";
4
- import { idCache as y } from "./index231.js";
4
+ import { idCache as y } from "./index211.js";
5
5
  function E(s, o = {}) {
6
6
  return {
7
7
  async request(p) {
@@ -4,10 +4,10 @@ import { encodeFunctionData as R } from "./index137.js";
4
4
  import { getChainContractAddress as b } from "./index173.js";
5
5
  import { trim as w } from "./index122.js";
6
6
  import { toHex as C } from "./index109.js";
7
- import { isNullUniversalResolverError as y } from "./index211.js";
7
+ import { isNullUniversalResolverError as y } from "./index212.js";
8
8
  import { localBatchGatewayUrl as x } from "./index163.js";
9
9
  import { namehash as i } from "./index112.js";
10
- import { packetToBytes as N } from "./index212.js";
10
+ import { packetToBytes as N } from "./index213.js";
11
11
  import { getAction as B } from "./index206.js";
12
12
  import { readContract as T } from "./index55.js";
13
13
  async function J(a, o) {
@@ -1,4 +1,4 @@
1
- import { parseAvatarRecord as m } from "./index213.js";
1
+ import { parseAvatarRecord as m } from "./index214.js";
2
2
  import { getAction as u } from "./index206.js";
3
3
  import { getEnsText as f } from "./index23.js";
4
4
  async function y(t, { blockNumber: a, blockTag: e, assetGatewayUrls: n, name: o, gatewayUrls: c, strict: i, universalResolverAddress: s }) {
@@ -1,8 +1,8 @@
1
1
  import { universalResolverReverseAbi as f } from "./index72.js";
2
2
  import { getChainContractAddress as u } from "./index173.js";
3
3
  import { toHex as h } from "./index109.js";
4
- import { isNullUniversalResolverError as p } from "./index211.js";
5
- import { packetToBytes as C } from "./index212.js";
4
+ import { isNullUniversalResolverError as p } from "./index212.js";
5
+ import { packetToBytes as C } from "./index213.js";
6
6
  import { getAction as w } from "./index206.js";
7
7
  import { readContract as A } from "./index55.js";
8
8
  async function b(e, { address: t, blockNumber: s, blockTag: i, gatewayUrls: a, strict: c, universalResolverAddress: d }) {
@@ -1,12 +1,15 @@
1
- import { panicReasons as a } from "./index86.js";
2
- import { BaseError as s } from "./index82.js";
3
- import { ContractFunctionRevertedError as t } from "./index85.js";
4
- function d(e, o) {
5
- if (!(e instanceof s))
6
- return !1;
7
- const r = e.walk((n) => n instanceof t);
8
- return r instanceof t ? !!(r.data?.errorName === "ResolverNotFound" || r.data?.errorName === "ResolverWildcardNotSupported" || r.data?.errorName === "ResolverNotContract" || r.data?.errorName === "ResolverError" || r.data?.errorName === "HttpError" || r.reason?.includes("Wildcard on non-extended resolvers is not supported") || o === "reverse" && r.reason === a[50]) : !1;
1
+ function r() {
2
+ return {
3
+ current: 0,
4
+ take() {
5
+ return this.current++;
6
+ },
7
+ reset() {
8
+ this.current = 0;
9
+ }
10
+ };
9
11
  }
12
+ const t = /* @__PURE__ */ r();
10
13
  export {
11
- d as isNullUniversalResolverError
14
+ t as idCache
12
15
  };
@@ -1,19 +1,12 @@
1
- import { stringToBytes as i } from "./index108.js";
2
- import { encodeLabelhash as h } from "./index244.js";
3
- import { labelhash as f } from "./index107.js";
4
- function y(s) {
5
- const o = s.replace(/^\.|\.$/gm, "");
6
- if (o.length === 0)
7
- return new Uint8Array(1);
8
- const e = new Uint8Array(i(o).byteLength + 2);
9
- let t = 0;
10
- const l = o.split(".");
11
- for (let r = 0; r < l.length; r++) {
12
- let n = i(l[r]);
13
- n.byteLength > 255 && (n = i(h(f(l[r])))), e[t] = n.length, e.set(n, t + 1), t += n.length + 1;
14
- }
15
- return e.byteLength !== t + 1 ? e.slice(0, t + 1) : e;
1
+ import { panicReasons as a } from "./index86.js";
2
+ import { BaseError as s } from "./index82.js";
3
+ import { ContractFunctionRevertedError as t } from "./index85.js";
4
+ function d(e, o) {
5
+ if (!(e instanceof s))
6
+ return !1;
7
+ const r = e.walk((n) => n instanceof t);
8
+ return r instanceof t ? !!(r.data?.errorName === "ResolverNotFound" || r.data?.errorName === "ResolverWildcardNotSupported" || r.data?.errorName === "ResolverNotContract" || r.data?.errorName === "ResolverError" || r.data?.errorName === "HttpError" || r.reason?.includes("Wildcard on non-extended resolvers is not supported") || o === "reverse" && r.reason === a[50]) : !1;
16
9
  }
17
10
  export {
18
- y as packetToBytes
11
+ d as isNullUniversalResolverError
19
12
  };
@@ -1,25 +1,19 @@
1
- import { parseAvatarUri as o, parseNftUri as f, getNftTokenUri as v, resolveAvatarUri as l, getJsonImage as A, getMetadataAvatarUri as N } from "./index245.js";
2
- async function b(r, { gatewayUrls: t, record: e }) {
3
- return /eip155:/i.test(e) ? U(r, { gatewayUrls: t, record: e }) : o({ uri: e, gatewayUrls: t });
4
- }
5
- async function U(r, { gatewayUrls: t, record: e }) {
6
- const i = f(e), s = await v(r, { nft: i }), { uri: a, isOnChain: c, isEncoded: p } = l({ uri: s, gatewayUrls: t });
7
- if (c && (a.includes("data:application/json;base64,") || a.startsWith("{"))) {
8
- const d = p ? (
9
- // if it is encoded, decode it
10
- atob(a.replace("data:application/json;base64,", ""))
11
- ) : (
12
- // if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
13
- a
14
- ), u = JSON.parse(d);
15
- return o({ uri: A(u), gatewayUrls: t });
1
+ import { stringToBytes as i } from "./index108.js";
2
+ import { encodeLabelhash as h } from "./index244.js";
3
+ import { labelhash as f } from "./index107.js";
4
+ function y(s) {
5
+ const o = s.replace(/^\.|\.$/gm, "");
6
+ if (o.length === 0)
7
+ return new Uint8Array(1);
8
+ const e = new Uint8Array(i(o).byteLength + 2);
9
+ let t = 0;
10
+ const l = o.split(".");
11
+ for (let r = 0; r < l.length; r++) {
12
+ let n = i(l[r]);
13
+ n.byteLength > 255 && (n = i(h(f(l[r])))), e[t] = n.length, e.set(n, t + 1), t += n.length + 1;
16
14
  }
17
- let n = i.tokenID;
18
- return i.namespace === "erc1155" && (n = n.replace("0x", "").padStart(64, "0")), N({
19
- gatewayUrls: t,
20
- uri: a.replace(/(?:0x)?{id}/, n)
21
- });
15
+ return e.byteLength !== t + 1 ? e.slice(0, t + 1) : e;
22
16
  }
23
17
  export {
24
- b as parseAvatarRecord
18
+ y as packetToBytes
25
19
  };
@@ -1,33 +1,25 @@
1
- import { fromNumber as a } from "./index246.js";
2
- import { toRpc as e } from "./index247.js";
3
- function n(t) {
4
- return {
5
- ...typeof t.baseFeePerGas == "bigint" && {
6
- baseFeePerGas: a(t.baseFeePerGas)
7
- },
8
- ...typeof t.blobBaseFee == "bigint" && {
9
- blobBaseFee: a(t.blobBaseFee)
10
- },
11
- ...typeof t.feeRecipient == "string" && {
12
- feeRecipient: t.feeRecipient
13
- },
14
- ...typeof t.gasLimit == "bigint" && {
15
- gasLimit: a(t.gasLimit)
16
- },
17
- ...typeof t.number == "bigint" && {
18
- number: a(t.number)
19
- },
20
- ...typeof t.prevRandao == "bigint" && {
21
- prevRandao: a(t.prevRandao)
22
- },
23
- ...typeof t.time == "bigint" && {
24
- time: a(t.time)
25
- },
26
- ...t.withdrawals && {
27
- withdrawals: t.withdrawals.map(e)
28
- }
29
- };
1
+ import { parseAvatarUri as o, parseNftUri as f, getNftTokenUri as v, resolveAvatarUri as l, getJsonImage as A, getMetadataAvatarUri as N } from "./index245.js";
2
+ async function b(r, { gatewayUrls: t, record: e }) {
3
+ return /eip155:/i.test(e) ? U(r, { gatewayUrls: t, record: e }) : o({ uri: e, gatewayUrls: t });
4
+ }
5
+ async function U(r, { gatewayUrls: t, record: e }) {
6
+ const i = f(e), s = await v(r, { nft: i }), { uri: a, isOnChain: c, isEncoded: p } = l({ uri: s, gatewayUrls: t });
7
+ if (c && (a.includes("data:application/json;base64,") || a.startsWith("{"))) {
8
+ const d = p ? (
9
+ // if it is encoded, decode it
10
+ atob(a.replace("data:application/json;base64,", ""))
11
+ ) : (
12
+ // if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
13
+ a
14
+ ), u = JSON.parse(d);
15
+ return o({ uri: A(u), gatewayUrls: t });
16
+ }
17
+ let n = i.tokenID;
18
+ return i.namespace === "erc1155" && (n = n.replace("0x", "").padStart(64, "0")), N({
19
+ gatewayUrls: t,
20
+ uri: a.replace(/(?:0x)?{id}/, n)
21
+ });
30
22
  }
31
23
  export {
32
- n as toRpc
24
+ b as parseAvatarRecord
33
25
  };
@@ -1,4 +1,33 @@
1
- const a = "0x82ad56cb";
1
+ import { fromNumber as a } from "./index246.js";
2
+ import { toRpc as e } from "./index247.js";
3
+ function n(t) {
4
+ return {
5
+ ...typeof t.baseFeePerGas == "bigint" && {
6
+ baseFeePerGas: a(t.baseFeePerGas)
7
+ },
8
+ ...typeof t.blobBaseFee == "bigint" && {
9
+ blobBaseFee: a(t.blobBaseFee)
10
+ },
11
+ ...typeof t.feeRecipient == "string" && {
12
+ feeRecipient: t.feeRecipient
13
+ },
14
+ ...typeof t.gasLimit == "bigint" && {
15
+ gasLimit: a(t.gasLimit)
16
+ },
17
+ ...typeof t.number == "bigint" && {
18
+ number: a(t.number)
19
+ },
20
+ ...typeof t.prevRandao == "bigint" && {
21
+ prevRandao: a(t.prevRandao)
22
+ },
23
+ ...typeof t.time == "bigint" && {
24
+ time: a(t.time)
25
+ },
26
+ ...t.withdrawals && {
27
+ withdrawals: t.withdrawals.map(e)
28
+ }
29
+ };
30
+ }
2
31
  export {
3
- a as aggregate3Signature
32
+ n as toRpc
4
33
  };
@@ -1,16 +1,4 @@
1
- import { CallExecutionError as c } from "./index85.js";
2
- import { UnknownNodeError as i } from "./index101.js";
3
- import { getNodeError as u } from "./index224.js";
4
- function a(r, { docsPath: t, ...o }) {
5
- const e = (() => {
6
- const n = u(r, o);
7
- return n instanceof i ? r : n;
8
- })();
9
- return new c(e, {
10
- docsPath: t,
11
- ...o
12
- });
13
- }
1
+ const a = "0x82ad56cb";
14
2
  export {
15
- a as getCallError
3
+ a as aggregate3Signature
16
4
  };
@@ -1,15 +1,16 @@
1
- function y(t, { format: r }) {
2
- if (!r)
3
- return {};
4
- const e = {};
5
- function i(c) {
6
- const s = Object.keys(c);
7
- for (const n of s)
8
- n in t && (e[n] = t[n]), c[n] && typeof c[n] == "object" && !Array.isArray(c[n]) && i(c[n]);
9
- }
10
- const o = r(t || {});
11
- return i(o), e;
1
+ import { CallExecutionError as c } from "./index85.js";
2
+ import { UnknownNodeError as i } from "./index101.js";
3
+ import { getNodeError as u } from "./index225.js";
4
+ function a(r, { docsPath: t, ...o }) {
5
+ const e = (() => {
6
+ const n = u(r, o);
7
+ return n instanceof i ? r : n;
8
+ })();
9
+ return new c(e, {
10
+ docsPath: t,
11
+ ...o
12
+ });
12
13
  }
13
14
  export {
14
- y as extract
15
+ a as getCallError
15
16
  };
@@ -1,50 +1,15 @@
1
- import { InvalidAddressError as a } from "./index104.js";
2
- import { InvalidBytesLengthError as d } from "./index105.js";
3
- import { AccountStateConflictError as u, StateAssignmentConflictError as h } from "./index92.js";
4
- import { isAddress as l } from "./index131.js";
5
- import { numberToHex as c } from "./index109.js";
6
- function s(r) {
7
- if (!(!r || r.length === 0))
8
- return r.reduce((t, { slot: e, value: n }) => {
9
- if (e.length !== 66)
10
- throw new d({
11
- size: e.length,
12
- targetSize: 66,
13
- type: "hex"
14
- });
15
- if (n.length !== 66)
16
- throw new d({
17
- size: n.length,
18
- targetSize: 66,
19
- type: "hex"
20
- });
21
- return t[e] = n, t;
22
- }, {});
23
- }
24
- function m(r) {
25
- const { balance: t, nonce: e, state: n, stateDiff: o, code: f } = r, i = {};
26
- if (f !== void 0 && (i.code = f), t !== void 0 && (i.balance = c(t)), e !== void 0 && (i.nonce = c(e)), n !== void 0 && (i.state = s(n)), o !== void 0) {
27
- if (i.state)
28
- throw new h();
29
- i.stateDiff = s(o);
30
- }
31
- return i;
32
- }
33
- function A(r) {
1
+ function y(t, { format: r }) {
34
2
  if (!r)
35
- return;
36
- const t = {};
37
- for (const { address: e, ...n } of r) {
38
- if (!l(e, { strict: !1 }))
39
- throw new a({ address: e });
40
- if (t[e])
41
- throw new u({ address: e });
42
- t[e] = m(n);
3
+ return {};
4
+ const e = {};
5
+ function i(c) {
6
+ const s = Object.keys(c);
7
+ for (const n of s)
8
+ n in t && (e[n] = t[n]), c[n] && typeof c[n] == "object" && !Array.isArray(c[n]) && i(c[n]);
43
9
  }
44
- return t;
10
+ const o = r(t || {});
11
+ return i(o), e;
45
12
  }
46
13
  export {
47
- m as serializeAccountStateOverride,
48
- s as serializeStateMapping,
49
- A as serializeStateOverride
14
+ y as extract
50
15
  };
@@ -1,12 +1,50 @@
1
- import { recoverAddress as i } from "./index149.js";
2
- import { hashAuthorization as e } from "./index248.js";
3
- async function a(o) {
4
- const { authorization: r, signature: t } = o;
5
- return i({
6
- hash: e(r),
7
- signature: t ?? r
8
- });
1
+ import { InvalidAddressError as a } from "./index104.js";
2
+ import { InvalidBytesLengthError as d } from "./index105.js";
3
+ import { AccountStateConflictError as u, StateAssignmentConflictError as h } from "./index92.js";
4
+ import { isAddress as l } from "./index131.js";
5
+ import { numberToHex as c } from "./index109.js";
6
+ function s(r) {
7
+ if (!(!r || r.length === 0))
8
+ return r.reduce((t, { slot: e, value: n }) => {
9
+ if (e.length !== 66)
10
+ throw new d({
11
+ size: e.length,
12
+ targetSize: 66,
13
+ type: "hex"
14
+ });
15
+ if (n.length !== 66)
16
+ throw new d({
17
+ size: n.length,
18
+ targetSize: 66,
19
+ type: "hex"
20
+ });
21
+ return t[e] = n, t;
22
+ }, {});
23
+ }
24
+ function m(r) {
25
+ const { balance: t, nonce: e, state: n, stateDiff: o, code: f } = r, i = {};
26
+ if (f !== void 0 && (i.code = f), t !== void 0 && (i.balance = c(t)), e !== void 0 && (i.nonce = c(e)), n !== void 0 && (i.state = s(n)), o !== void 0) {
27
+ if (i.state)
28
+ throw new h();
29
+ i.stateDiff = s(o);
30
+ }
31
+ return i;
32
+ }
33
+ function A(r) {
34
+ if (!r)
35
+ return;
36
+ const t = {};
37
+ for (const { address: e, ...n } of r) {
38
+ if (!l(e, { strict: !1 }))
39
+ throw new a({ address: e });
40
+ if (t[e])
41
+ throw new u({ address: e });
42
+ t[e] = m(n);
43
+ }
44
+ return t;
9
45
  }
10
46
  export {
11
- a as recoverAuthorizationAddress
47
+ m as serializeAccountStateOverride,
48
+ s as serializeStateMapping,
49
+ A as serializeStateOverride
12
50
  };
@@ -1,6 +1,6 @@
1
1
  import { getChainContractAddress as l } from "./index173.js";
2
2
  import { toHex as u } from "./index109.js";
3
- import { packetToBytes as v } from "./index212.js";
3
+ import { packetToBytes as v } from "./index213.js";
4
4
  import { getAction as f } from "./index206.js";
5
5
  import { readContract as m } from "./index55.js";
6
6
  async function A(o, r) {