UNPKG
@getclave/permissionless
Version:
latest (0.4.3)
0.4.3
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.2.39
A utility library for working with ERC-4337
docs.pimlico.io/permissionless
@getclave/permissionless
/
utils
/
getAddressFromInitCodeOrPaymasterAndData.ts
14 lines
(12 loc)
•
307 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import
{
type
Address
,
type
Hex
, getAddress }
from
"viem"
export
function
getAddressFromInitCodeOrPaymasterAndData
(
data
:
Hex
):
Address
|
undefined
{
if
(!data) {
return
undefined
}
if
(data.
length
>=
42
) {
return
getAddress
(data.
slice
(
0
,
42
)) }
return
undefined
}