@coinbase/cdp-hooks 0.0.32 → 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 +155 -7
- package/dist/esm/index.js +18 -15
- package/dist/esm/index15.js +1 -1
- package/dist/esm/index19.js +3 -3
- package/dist/esm/index190.js +40 -7
- package/dist/esm/index191.js +2 -7
- package/dist/esm/index192.js +4 -36
- package/dist/esm/index193.js +10 -15
- package/dist/esm/index194.js +19 -8
- package/dist/esm/index195.js +7 -40
- package/dist/esm/index196.js +12 -2
- package/dist/esm/index197.js +66 -4
- package/dist/esm/index198.js +64 -9
- package/dist/esm/index199.js +183 -17
- package/dist/esm/index20.js +2 -2
- package/dist/esm/index200.js +22 -7
- package/dist/esm/index201.js +41 -10
- package/dist/esm/index202.js +72 -62
- package/dist/esm/index203.js +36 -61
- package/dist/esm/index204.js +15 -184
- package/dist/esm/index205.js +12 -21
- package/dist/esm/index206.js +7 -42
- package/dist/esm/index207.js +6 -76
- package/dist/esm/index208.js +36 -40
- package/dist/esm/index209.js +15 -16
- package/dist/esm/index21.js +3 -3
- package/dist/esm/index210.js +8 -13
- package/dist/esm/index212.js +9 -11
- package/dist/esm/index213.js +16 -9
- package/dist/esm/index214.js +21 -15
- package/dist/esm/index215.js +30 -22
- package/dist/esm/index216.js +2 -31
- package/dist/esm/index217.js +14 -2
- package/dist/esm/index218.js +12 -13
- package/dist/esm/index219.js +45 -10
- package/dist/esm/index22.js +2 -2
- package/dist/esm/index220.js +9 -47
- package/dist/esm/index221.js +12 -8
- package/dist/esm/index222.js +14 -13
- package/dist/esm/index223.js +8 -14
- package/dist/esm/index224.js +13 -6
- package/dist/esm/index225.js +24 -15
- package/dist/esm/index226.js +11 -24
- package/dist/esm/index227.js +23 -10
- package/dist/esm/index228.js +51 -24
- package/dist/esm/index229.js +17 -51
- package/dist/esm/index23.js +3 -3
- package/dist/esm/index230.js +14 -17
- package/dist/esm/index231.js +11 -14
- package/dist/esm/index236.js +1 -1
- package/dist/esm/index24.js +6 -6
- package/dist/esm/index244.js +3 -16
- package/dist/esm/index245.js +136 -3
- package/dist/esm/index246.js +144 -125
- package/dist/esm/index247.js +9 -155
- package/dist/esm/index248.js +16 -9
- package/dist/esm/index249.js +3 -3
- package/dist/esm/index25.js +2 -2
- package/dist/esm/index250.js +1 -1
- package/dist/esm/index259.js +1 -1
- package/dist/esm/index26.js +1 -1
- package/dist/esm/index260.js +1 -1
- package/dist/esm/index264.js +1 -1
- package/dist/esm/index265.js +1 -1
- package/dist/esm/index27.js +1 -1
- package/dist/esm/index28.js +1 -1
- package/dist/esm/index29.js +1 -1
- package/dist/esm/index3.js +95 -85
- package/dist/esm/index30.js +1 -1
- package/dist/esm/index31.js +1 -1
- package/dist/esm/index32.js +4 -4
- package/dist/esm/index33.js +1 -1
- package/dist/esm/index41.js +1 -1
- package/dist/esm/index42.js +2 -2
- package/dist/esm/index43.js +1 -1
- package/dist/esm/index48.js +1 -1
- package/dist/esm/index51.js +1 -1
- package/dist/esm/index54.js +1 -1
- package/dist/esm/index55.js +1 -1
- package/dist/esm/index56.js +3 -3
- package/dist/esm/index57.js +2 -2
- package/dist/esm/index58.js +1 -1
- package/dist/esm/index60.js +1 -1
- package/dist/esm/index61.js +1 -1
- package/dist/esm/index62.js +3 -3
- package/dist/esm/index63.js +3 -3
- package/dist/esm/index64.js +3 -3
- package/dist/esm/index65.js +3 -3
- package/dist/esm/index66.js +3 -3
- package/dist/esm/index67.js +3 -3
- package/dist/esm/index68.js +3 -3
- package/dist/esm/index69.js +1 -1
- package/dist/esm/index71.js +1 -1
- package/dist/types/index.d.ts +17 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -153,6 +153,27 @@ function App() {
|
|
|
153
153
|
|
|
154
154
|
* When `createAccountOnLogin` is set to `"evm-smart"`, new users will automatically get both an EOA and a Smart Account.
|
|
155
155
|
|
|
156
|
+
#### Solana Configuration
|
|
157
|
+
|
|
158
|
+
You can configure the provider to create Solana accounts for new users:
|
|
159
|
+
|
|
160
|
+
```tsx lines
|
|
161
|
+
function App() {
|
|
162
|
+
return (
|
|
163
|
+
<CDPHooksProvider
|
|
164
|
+
config={{
|
|
165
|
+
projectId: "your-project-id",
|
|
166
|
+
createAccountOnLogin: "solana", // Creates Solana accounts instead of EVM accounts
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
<App />
|
|
170
|
+
</CDPHooksProvider>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
* When `createAccountOnLogin` is set to `"solana"`, new users will automatically get a Solana account instead of EVM accounts.
|
|
176
|
+
|
|
156
177
|
### Sign In a User
|
|
157
178
|
|
|
158
179
|
End user authentication proceeds in two steps:
|
|
@@ -184,8 +205,17 @@ function SignIn() {
|
|
|
184
205
|
});
|
|
185
206
|
|
|
186
207
|
console.log("Signed in user:", user);
|
|
187
|
-
|
|
188
|
-
|
|
208
|
+
|
|
209
|
+
// Access different account types based on configuration
|
|
210
|
+
if (user.evmAccounts?.length > 0) {
|
|
211
|
+
console.log("User EVM address (EOA):", user.evmAccounts[0]);
|
|
212
|
+
}
|
|
213
|
+
if (user.evmSmartAccounts?.length > 0) {
|
|
214
|
+
console.log("User Smart Account:", user.evmSmartAccounts[0]);
|
|
215
|
+
}
|
|
216
|
+
if (user.solanaAccounts?.length > 0) {
|
|
217
|
+
console.log("User Solana address:", user.solanaAccounts[0]);
|
|
218
|
+
}
|
|
189
219
|
} catch (error) {
|
|
190
220
|
console.error("Sign in failed:", error);
|
|
191
221
|
}
|
|
@@ -334,11 +364,129 @@ function UserInformation() {
|
|
|
334
364
|
<div>
|
|
335
365
|
<h2>User Information</h2>
|
|
336
366
|
<p>User ID: {user.userId}</p>
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
<p>
|
|
340
|
-
|
|
341
|
-
|
|
367
|
+
|
|
368
|
+
<>
|
|
369
|
+
<p>EVM Address (EOA): {evmAddress}</p>
|
|
370
|
+
{user.evmSmartAccounts?.[0] && (
|
|
371
|
+
<p>Smart Account: {user.evmSmartAccounts[0]}</p>
|
|
372
|
+
)}
|
|
373
|
+
</>
|
|
374
|
+
|
|
375
|
+
{emailAddress && <p>Email Address: {emailAddress}</p>}
|
|
376
|
+
</div>
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Working with Solana
|
|
382
|
+
|
|
383
|
+
When your application is configured with `createAccountOnLogin: "solana"`, you can use Solana-specific hooks to interact with Solana accounts.
|
|
384
|
+
|
|
385
|
+
#### Access Solana Address
|
|
386
|
+
|
|
387
|
+
Use the `useSolanaAddress` hook to get the user's primary Solana address:
|
|
388
|
+
|
|
389
|
+
```tsx lines
|
|
390
|
+
import { useSolanaAddress } from "@coinbase/cdp-hooks";
|
|
391
|
+
|
|
392
|
+
function SolanaWallet() {
|
|
393
|
+
const { solanaAddress } = useSolanaAddress();
|
|
394
|
+
|
|
395
|
+
if (!solanaAddress) {
|
|
396
|
+
return <div>No Solana wallet connected</div>;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<div>
|
|
401
|
+
<h3>Your Solana Wallet</h3>
|
|
402
|
+
<p>Address: {solanaAddress}</p>
|
|
403
|
+
</div>
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
#### Sign a Solana Transaction
|
|
409
|
+
|
|
410
|
+
Use the `useSignSolanaTransaction` hook to sign Solana transactions:
|
|
411
|
+
|
|
412
|
+
```tsx lines
|
|
413
|
+
import { useSignSolanaTransaction, useSolanaAddress } from "@coinbase/cdp-hooks";
|
|
414
|
+
|
|
415
|
+
function SolanaTransactionSigner() {
|
|
416
|
+
const { signSolanaTransaction } = useSignSolanaTransaction();
|
|
417
|
+
const { solanaAddress } = useSolanaAddress();
|
|
418
|
+
|
|
419
|
+
const handleSignTransaction = async () => {
|
|
420
|
+
if (!solanaAddress) return;
|
|
421
|
+
|
|
422
|
+
try {
|
|
423
|
+
const result = await signSolanaTransaction({
|
|
424
|
+
solanaAccount: solanaAddress,
|
|
425
|
+
transaction: "base64-encoded-solana-transaction" // Your Solana transaction here
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
console.log("Signed Transaction:", result.signedTransaction);
|
|
429
|
+
// The signedTransaction can now be broadcast to the Solana network
|
|
430
|
+
} catch (error) {
|
|
431
|
+
console.error("Failed to sign transaction:", error);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
if (!solanaAddress) {
|
|
436
|
+
return <div>Please connect your Solana wallet first</div>;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return (
|
|
440
|
+
<div>
|
|
441
|
+
<h3>Sign Solana Transaction</h3>
|
|
442
|
+
<button onClick={handleSignTransaction}>
|
|
443
|
+
Sign Transaction
|
|
444
|
+
</button>
|
|
445
|
+
</div>
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
#### Send a Solana Transaction
|
|
451
|
+
|
|
452
|
+
Use the `useSendSolanaTransaction` hook to sign and send Solana transactions in a single action. This is supported on:
|
|
453
|
+
- Solana Mainnet
|
|
454
|
+
- Solana Devnet
|
|
455
|
+
|
|
456
|
+
```tsx lines
|
|
457
|
+
import { useSendSolanaTransaction, useSolanaAddress } from "@coinbase/cdp-hooks";
|
|
458
|
+
|
|
459
|
+
function SolanaTransactionSender() {
|
|
460
|
+
const { sendSolanaTransaction } = useSendSolanaTransaction();
|
|
461
|
+
const { solanaAddress } = useSolanaAddress();
|
|
462
|
+
|
|
463
|
+
const handleSendTransaction = async () => {
|
|
464
|
+
if (!solanaAddress) return;
|
|
465
|
+
|
|
466
|
+
try {
|
|
467
|
+
const result = await sendSolanaTransaction({
|
|
468
|
+
solanaAccount: solanaAddress,
|
|
469
|
+
network: "solana-devnet", // or "solana" for mainnet
|
|
470
|
+
transaction: "base64-encoded-solana-transaction" // Your Solana transaction here
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
console.log("Transaction Signature:", result.transactionSignature);
|
|
474
|
+
// The transaction has been broadcast to the Solana network
|
|
475
|
+
} catch (error) {
|
|
476
|
+
console.error("Failed to send transaction:", error);
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
if (!solanaAddress) {
|
|
481
|
+
return <div>Please connect your Solana wallet first</div>;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return (
|
|
485
|
+
<div>
|
|
486
|
+
<h3>Send Solana Transaction</h3>
|
|
487
|
+
<button onClick={handleSendTransaction}>
|
|
488
|
+
Send Transaction
|
|
489
|
+
</button>
|
|
342
490
|
</div>
|
|
343
491
|
);
|
|
344
492
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { APIError as n } from "@coinbase/cdp-core";
|
|
2
2
|
import { CDPContext as i, CDPHooksProvider as u } from "./index2.js";
|
|
3
|
-
import { useConfig as o, useCurrentUser as
|
|
3
|
+
import { useConfig as o, useCurrentUser as t, useEnforceAuthenticated as S, useEnforceUnauthenticated as m, useEvmAddress as d, useExportEvmAccount as E, useGetAccessToken as c, useIsInitialized as g, useIsSignedIn as f, useSendEvmTransaction as v, useSendSolanaTransaction as T, useSendUserOperation as p, useSignEvmHash as I, useSignEvmMessage as l, useSignEvmTransaction as A, useSignEvmTypedData as P, useSignInWithEmail as h, useSignInWithSms as x, useSignOut as C, useSignSolanaTransaction as O, useSolanaAddress as U, useVerifyEmailOTP as y, useVerifySmsOTP as D, useWaitForUserOperation as W } from "./index3.js";
|
|
4
4
|
export {
|
|
5
5
|
n as APIError,
|
|
6
6
|
i as CDPContext,
|
|
7
7
|
u as CDPHooksProvider,
|
|
8
8
|
o as useConfig,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
t as useCurrentUser,
|
|
10
|
+
S as useEnforceAuthenticated,
|
|
11
|
+
m as useEnforceUnauthenticated,
|
|
12
|
+
d as useEvmAddress,
|
|
13
|
+
E as useExportEvmAccount,
|
|
14
|
+
c as useGetAccessToken,
|
|
15
15
|
g as useIsInitialized,
|
|
16
16
|
f as useIsSignedIn,
|
|
17
17
|
v as useSendEvmTransaction,
|
|
18
|
+
T as useSendSolanaTransaction,
|
|
18
19
|
p as useSendUserOperation,
|
|
19
20
|
I as useSignEvmHash,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
l as useSignEvmMessage,
|
|
22
|
+
A as useSignEvmTransaction,
|
|
23
|
+
P as useSignEvmTypedData,
|
|
24
|
+
h as useSignInWithEmail,
|
|
25
|
+
x as useSignInWithSms,
|
|
25
26
|
C as useSignOut,
|
|
26
|
-
O as
|
|
27
|
-
U as
|
|
28
|
-
|
|
27
|
+
O as useSignSolanaTransaction,
|
|
28
|
+
U as useSolanaAddress,
|
|
29
|
+
y as useVerifyEmailOTP,
|
|
30
|
+
D as useVerifySmsOTP,
|
|
31
|
+
W as useWaitForUserOperation
|
|
29
32
|
};
|
package/dist/esm/index15.js
CHANGED
package/dist/esm/index19.js
CHANGED
|
@@ -4,11 +4,11 @@ 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 "./
|
|
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 "./
|
|
11
|
-
import { getAction as B } from "./
|
|
10
|
+
import { packetToBytes as N } from "./index213.js";
|
|
11
|
+
import { getAction as B } from "./index206.js";
|
|
12
12
|
import { readContract as T } from "./index55.js";
|
|
13
13
|
async function J(a, o) {
|
|
14
14
|
const { blockNumber: l, blockTag: m, coinType: t, name: e, gatewayUrls: f, strict: v } = o, { chain: n } = a, p = (() => {
|
package/dist/esm/index190.js
CHANGED
|
@@ -1,10 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { version as u } from "./index191.js";
|
|
2
|
+
class a extends Error {
|
|
3
|
+
constructor(i, e = {}) {
|
|
4
|
+
const t = e.cause instanceof a ? e.cause.details : e.cause?.message ? e.cause.message : e.details, s = e.cause instanceof a && e.cause.docsPath || e.docsPath, r = [
|
|
5
|
+
i || "An error occurred.",
|
|
6
|
+
"",
|
|
7
|
+
...e.metaMessages ? [...e.metaMessages, ""] : [],
|
|
8
|
+
...s ? [`Docs: https://abitype.dev${s}`] : [],
|
|
9
|
+
...t ? [`Details: ${t}`] : [],
|
|
10
|
+
`Version: abitype@${u}`
|
|
11
|
+
].join(`
|
|
12
|
+
`);
|
|
13
|
+
super(r), Object.defineProperty(this, "details", {
|
|
14
|
+
enumerable: !0,
|
|
15
|
+
configurable: !0,
|
|
16
|
+
writable: !0,
|
|
17
|
+
value: void 0
|
|
18
|
+
}), Object.defineProperty(this, "docsPath", {
|
|
19
|
+
enumerable: !0,
|
|
20
|
+
configurable: !0,
|
|
21
|
+
writable: !0,
|
|
22
|
+
value: void 0
|
|
23
|
+
}), Object.defineProperty(this, "metaMessages", {
|
|
24
|
+
enumerable: !0,
|
|
25
|
+
configurable: !0,
|
|
26
|
+
writable: !0,
|
|
27
|
+
value: void 0
|
|
28
|
+
}), Object.defineProperty(this, "shortMessage", {
|
|
29
|
+
enumerable: !0,
|
|
30
|
+
configurable: !0,
|
|
31
|
+
writable: !0,
|
|
32
|
+
value: void 0
|
|
33
|
+
}), Object.defineProperty(this, "name", {
|
|
34
|
+
enumerable: !0,
|
|
35
|
+
configurable: !0,
|
|
36
|
+
writable: !0,
|
|
37
|
+
value: "AbiTypeError"
|
|
38
|
+
}), e.cause && (this.cause = e.cause), this.details = t, this.docsPath = s, this.metaMessages = e.metaMessages, this.shortMessage = i;
|
|
39
|
+
}
|
|
7
40
|
}
|
|
8
41
|
export {
|
|
9
|
-
|
|
42
|
+
a as BaseError
|
|
10
43
|
};
|
package/dist/esm/index191.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const t = {};
|
|
3
|
-
return e.transport.type === "fallback" && e.transport.onResponse?.(({ method: s, response: o, status: p, transport: n }) => {
|
|
4
|
-
p === "success" && r === s && (t[o] = n.request);
|
|
5
|
-
}), (s) => t[s] || e.request;
|
|
6
|
-
}
|
|
1
|
+
const o = "1.0.8";
|
|
7
2
|
export {
|
|
8
|
-
|
|
3
|
+
o as version
|
|
9
4
|
};
|
package/dist/esm/index192.js
CHANGED
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
const i = ++w, c = () => f.get(s) || [], g = () => {
|
|
5
|
-
const n = c();
|
|
6
|
-
f.set(s, n.filter((e) => e.id !== i));
|
|
7
|
-
}, r = () => {
|
|
8
|
-
const n = c();
|
|
9
|
-
if (!n.some((t) => t.id === i))
|
|
10
|
-
return;
|
|
11
|
-
const e = p.get(s);
|
|
12
|
-
if (n.length === 1 && e) {
|
|
13
|
-
const t = e();
|
|
14
|
-
t instanceof Promise && t.catch(() => {
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
g();
|
|
18
|
-
}, o = c();
|
|
19
|
-
if (f.set(s, [
|
|
20
|
-
...o,
|
|
21
|
-
{ id: i, fns: l }
|
|
22
|
-
]), o && o.length > 0)
|
|
23
|
-
return r;
|
|
24
|
-
const u = {};
|
|
25
|
-
for (const n in l)
|
|
26
|
-
u[n] = (...e) => {
|
|
27
|
-
const t = c();
|
|
28
|
-
if (t.length !== 0)
|
|
29
|
-
for (const m of t)
|
|
30
|
-
m.fns[n]?.(...e);
|
|
31
|
-
};
|
|
32
|
-
const a = h(u);
|
|
33
|
-
return typeof a == "function" && p.set(s, a), r;
|
|
1
|
+
import { formatAbiParameters as r } from "./index193.js";
|
|
2
|
+
function e(t) {
|
|
3
|
+
return t.type === "function" ? `function ${t.name}(${r(t.inputs)})${t.stateMutability && t.stateMutability !== "nonpayable" ? ` ${t.stateMutability}` : ""}${t.outputs?.length ? ` returns (${r(t.outputs)})` : ""}` : t.type === "event" ? `event ${t.name}(${r(t.inputs)})` : t.type === "error" ? `error ${t.name}(${r(t.inputs)})` : t.type === "constructor" ? `constructor(${r(t.inputs)})${t.stateMutability === "payable" ? " payable" : ""}` : t.type === "fallback" ? `fallback() external${t.stateMutability === "payable" ? " payable" : ""}` : "receive() external payable";
|
|
34
4
|
}
|
|
35
5
|
export {
|
|
36
|
-
|
|
37
|
-
f as listenersCache,
|
|
38
|
-
C as observe
|
|
6
|
+
e as formatAbiItem
|
|
39
7
|
};
|
package/dist/esm/index193.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
function
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const c = async () => {
|
|
11
|
-
n && (await a({ unpoll: t }), await l(i), c());
|
|
12
|
-
};
|
|
13
|
-
c();
|
|
14
|
-
})(), t;
|
|
1
|
+
import { formatAbiParameter as m } from "./index194.js";
|
|
2
|
+
function f(e) {
|
|
3
|
+
let r = "";
|
|
4
|
+
const o = e.length;
|
|
5
|
+
for (let t = 0; t < o; t++) {
|
|
6
|
+
const a = e[t];
|
|
7
|
+
r += m(a), t !== o - 1 && (r += ", ");
|
|
8
|
+
}
|
|
9
|
+
return r;
|
|
15
10
|
}
|
|
16
11
|
export {
|
|
17
|
-
|
|
12
|
+
f as formatAbiParameters
|
|
18
13
|
};
|
package/dist/esm/index194.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { execTyped as f } from "./index195.js";
|
|
2
|
+
const p = /^tuple(?<array>(\[(\d*)\])*)$/;
|
|
3
|
+
function c(n) {
|
|
4
|
+
let t = n.type;
|
|
5
|
+
if (p.test(n.type) && "components" in n) {
|
|
6
|
+
t = "(";
|
|
7
|
+
const e = n.components.length;
|
|
8
|
+
for (let o = 0; o < e; o++) {
|
|
9
|
+
const d = n.components[o];
|
|
10
|
+
t += c(d), o < e - 1 && (t += ", ");
|
|
11
|
+
}
|
|
12
|
+
const s = f(p, n.type);
|
|
13
|
+
return t += `)${s?.array ?? ""}`, c({
|
|
14
|
+
...n,
|
|
15
|
+
type: t
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return "indexed" in n && n.indexed && (t = `${t} indexed`), n.name ? `${t} ${n.name}` : t;
|
|
8
19
|
}
|
|
9
20
|
export {
|
|
10
|
-
|
|
21
|
+
c as formatAbiParameter
|
|
11
22
|
};
|
package/dist/esm/index195.js
CHANGED
|
@@ -1,43 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
constructor(i, e = {}) {
|
|
4
|
-
const t = e.cause instanceof a ? e.cause.details : e.cause?.message ? e.cause.message : e.details, s = e.cause instanceof a && e.cause.docsPath || e.docsPath, r = [
|
|
5
|
-
i || "An error occurred.",
|
|
6
|
-
"",
|
|
7
|
-
...e.metaMessages ? [...e.metaMessages, ""] : [],
|
|
8
|
-
...s ? [`Docs: https://abitype.dev${s}`] : [],
|
|
9
|
-
...t ? [`Details: ${t}`] : [],
|
|
10
|
-
`Version: abitype@${u}`
|
|
11
|
-
].join(`
|
|
12
|
-
`);
|
|
13
|
-
super(r), Object.defineProperty(this, "details", {
|
|
14
|
-
enumerable: !0,
|
|
15
|
-
configurable: !0,
|
|
16
|
-
writable: !0,
|
|
17
|
-
value: void 0
|
|
18
|
-
}), Object.defineProperty(this, "docsPath", {
|
|
19
|
-
enumerable: !0,
|
|
20
|
-
configurable: !0,
|
|
21
|
-
writable: !0,
|
|
22
|
-
value: void 0
|
|
23
|
-
}), Object.defineProperty(this, "metaMessages", {
|
|
24
|
-
enumerable: !0,
|
|
25
|
-
configurable: !0,
|
|
26
|
-
writable: !0,
|
|
27
|
-
value: void 0
|
|
28
|
-
}), Object.defineProperty(this, "shortMessage", {
|
|
29
|
-
enumerable: !0,
|
|
30
|
-
configurable: !0,
|
|
31
|
-
writable: !0,
|
|
32
|
-
value: void 0
|
|
33
|
-
}), Object.defineProperty(this, "name", {
|
|
34
|
-
enumerable: !0,
|
|
35
|
-
configurable: !0,
|
|
36
|
-
writable: !0,
|
|
37
|
-
value: "AbiTypeError"
|
|
38
|
-
}), e.cause && (this.cause = e.cause), this.details = t, this.docsPath = s, this.metaMessages = e.metaMessages, this.shortMessage = i;
|
|
39
|
-
}
|
|
1
|
+
function n(e, t) {
|
|
2
|
+
return e.exec(t)?.groups;
|
|
40
3
|
}
|
|
4
|
+
const s = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, o = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/, x = /^\(.+?\).*?$/;
|
|
41
5
|
export {
|
|
42
|
-
|
|
6
|
+
s as bytesRegex,
|
|
7
|
+
n as execTyped,
|
|
8
|
+
o as integerRegex,
|
|
9
|
+
x as isTupleRegex
|
|
43
10
|
};
|
package/dist/esm/index196.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { isStructSignature as c } from "./index197.js";
|
|
2
|
+
import { parseStructs as s } from "./index198.js";
|
|
3
|
+
import { parseSignature as p } from "./index199.js";
|
|
4
|
+
function a(t) {
|
|
5
|
+
const i = s(t), o = [], e = t.length;
|
|
6
|
+
for (let r = 0; r < e; r++) {
|
|
7
|
+
const n = t[r];
|
|
8
|
+
c(n) || o.push(p(n, i));
|
|
9
|
+
}
|
|
10
|
+
return o;
|
|
11
|
+
}
|
|
2
12
|
export {
|
|
3
|
-
|
|
13
|
+
a as parseAbi
|
|
4
14
|
};
|
package/dist/esm/index197.js
CHANGED
|
@@ -1,7 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { execTyped as t } from "./index195.js";
|
|
2
|
+
const n = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
|
|
3
|
+
function g(e) {
|
|
4
|
+
return n.test(e);
|
|
4
5
|
}
|
|
6
|
+
function S(e) {
|
|
7
|
+
return t(n, e);
|
|
8
|
+
}
|
|
9
|
+
const r = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
|
|
10
|
+
function l(e) {
|
|
11
|
+
return r.test(e);
|
|
12
|
+
}
|
|
13
|
+
function f(e) {
|
|
14
|
+
return t(r, e);
|
|
15
|
+
}
|
|
16
|
+
const a = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
|
|
17
|
+
function x(e) {
|
|
18
|
+
return a.test(e);
|
|
19
|
+
}
|
|
20
|
+
function p(e) {
|
|
21
|
+
return t(a, e);
|
|
22
|
+
}
|
|
23
|
+
const u = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
|
|
24
|
+
function $(e) {
|
|
25
|
+
return u.test(e);
|
|
26
|
+
}
|
|
27
|
+
function b(e) {
|
|
28
|
+
return t(u, e);
|
|
29
|
+
}
|
|
30
|
+
const i = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;
|
|
31
|
+
function m(e) {
|
|
32
|
+
return i.test(e);
|
|
33
|
+
}
|
|
34
|
+
function y(e) {
|
|
35
|
+
return t(i, e);
|
|
36
|
+
}
|
|
37
|
+
const c = /^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;
|
|
38
|
+
function v(e) {
|
|
39
|
+
return c.test(e);
|
|
40
|
+
}
|
|
41
|
+
function z(e) {
|
|
42
|
+
return t(c, e);
|
|
43
|
+
}
|
|
44
|
+
const o = /^receive\(\) external payable$/;
|
|
45
|
+
function A(e) {
|
|
46
|
+
return o.test(e);
|
|
47
|
+
}
|
|
48
|
+
const R = /* @__PURE__ */ new Set(["indexed"]), Z = /* @__PURE__ */ new Set([
|
|
49
|
+
"calldata",
|
|
50
|
+
"memory",
|
|
51
|
+
"storage"
|
|
52
|
+
]);
|
|
5
53
|
export {
|
|
6
|
-
|
|
54
|
+
R as eventModifiers,
|
|
55
|
+
y as execConstructorSignature,
|
|
56
|
+
S as execErrorSignature,
|
|
57
|
+
f as execEventSignature,
|
|
58
|
+
z as execFallbackSignature,
|
|
59
|
+
p as execFunctionSignature,
|
|
60
|
+
b as execStructSignature,
|
|
61
|
+
Z as functionModifiers,
|
|
62
|
+
m as isConstructorSignature,
|
|
63
|
+
g as isErrorSignature,
|
|
64
|
+
l as isEventSignature,
|
|
65
|
+
v as isFallbackSignature,
|
|
66
|
+
x as isFunctionSignature,
|
|
67
|
+
A as isReceiveSignature,
|
|
68
|
+
$ as isStructSignature
|
|
7
69
|
};
|
package/dist/esm/index198.js
CHANGED
|
@@ -1,13 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { isTupleRegex as g, execTyped as w } from "./index195.js";
|
|
2
|
+
import { UnknownTypeError as S } from "./index201.js";
|
|
3
|
+
import { InvalidAbiTypeParameterError as d } from "./index202.js";
|
|
4
|
+
import { InvalidSignatureError as T, InvalidStructSignatureError as v } from "./index203.js";
|
|
5
|
+
import { CircularReferenceError as x } from "./index205.js";
|
|
6
|
+
import { isStructSignature as E, execStructSignature as b } from "./index197.js";
|
|
7
|
+
import { parseAbiParameter as A, isSolidityType as $ } from "./index199.js";
|
|
8
|
+
function C(s) {
|
|
9
|
+
const n = {}, c = s.length;
|
|
10
|
+
for (let t = 0; t < c; t++) {
|
|
11
|
+
const i = s[t];
|
|
12
|
+
if (!E(i))
|
|
13
|
+
continue;
|
|
14
|
+
const r = b(i);
|
|
15
|
+
if (!r)
|
|
16
|
+
throw new T({ signature: i, type: "struct" });
|
|
17
|
+
const u = r.properties.split(";"), e = [], h = u.length;
|
|
18
|
+
for (let l = 0; l < h; l++) {
|
|
19
|
+
const m = u[l].trim();
|
|
20
|
+
if (!m)
|
|
21
|
+
continue;
|
|
22
|
+
const y = A(m, {
|
|
23
|
+
type: "struct"
|
|
24
|
+
});
|
|
25
|
+
e.push(y);
|
|
26
|
+
}
|
|
27
|
+
if (!e.length)
|
|
28
|
+
throw new v({ signature: i });
|
|
29
|
+
n[r.name] = e;
|
|
8
30
|
}
|
|
9
|
-
|
|
31
|
+
const o = {}, a = Object.entries(n), p = a.length;
|
|
32
|
+
for (let t = 0; t < p; t++) {
|
|
33
|
+
const [i, r] = a[t];
|
|
34
|
+
o[i] = f(r, n);
|
|
35
|
+
}
|
|
36
|
+
return o;
|
|
37
|
+
}
|
|
38
|
+
const I = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
|
|
39
|
+
function f(s, n, c = /* @__PURE__ */ new Set()) {
|
|
40
|
+
const o = [], a = s.length;
|
|
41
|
+
for (let p = 0; p < a; p++) {
|
|
42
|
+
const t = s[p];
|
|
43
|
+
if (g.test(t.type))
|
|
44
|
+
o.push(t);
|
|
45
|
+
else {
|
|
46
|
+
const r = w(I, t.type);
|
|
47
|
+
if (!r?.type)
|
|
48
|
+
throw new d({ abiParameter: t });
|
|
49
|
+
const { array: u, type: e } = r;
|
|
50
|
+
if (e in n) {
|
|
51
|
+
if (c.has(e))
|
|
52
|
+
throw new x({ type: e });
|
|
53
|
+
o.push({
|
|
54
|
+
...t,
|
|
55
|
+
type: `tuple${u ?? ""}`,
|
|
56
|
+
components: f(n[e] ?? [], n, /* @__PURE__ */ new Set([...c, e]))
|
|
57
|
+
});
|
|
58
|
+
} else if ($(e))
|
|
59
|
+
o.push(t);
|
|
60
|
+
else
|
|
61
|
+
throw new S({ type: e });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return o;
|
|
10
65
|
}
|
|
11
66
|
export {
|
|
12
|
-
|
|
67
|
+
C as parseStructs
|
|
13
68
|
};
|