Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
36da4222
Commit
36da4222
authored
Mar 01, 2023
by
Will Cory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug with 0x0
parent
4f5cc382
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
parseAttestationBytes.spec.ts
packages/atst/src/lib/parseAttestationBytes.spec.ts
+12
-2
parseAttestationBytes.ts
packages/atst/src/lib/parseAttestationBytes.ts
+1
-1
No files found.
packages/atst/src/lib/parseAttestationBytes.spec.ts
View file @
36da4222
...
@@ -41,8 +41,11 @@ describe(parseAttestationBytes.name, () => {
...
@@ -41,8 +41,11 @@ describe(parseAttestationBytes.name, () => {
})
})
it
(
'
should work for raw bytes
'
,
()
=>
{
it
(
'
should work for raw bytes
'
,
()
=>
{
const
bytes
=
'
0x420
'
expect
(
parseAttestationBytes
(
'
0x420
'
,
'
bytes
'
)).
toMatchInlineSnapshot
(
expect
(
parseAttestationBytes
(
bytes
,
'
bytes
'
)).
toBe
(
bytes
)
'
"0x420"
'
)
expect
(
parseAttestationBytes
(
'
0x
'
,
'
string
'
)).
toMatchInlineSnapshot
(
'
""
'
)
expect
(
parseAttestationBytes
(
'
0x0
'
,
'
string
'
)).
toMatchInlineSnapshot
(
'
""
'
)
})
})
it
(
'
should return raw bytes for invalid type
'
,
()
=>
{
it
(
'
should return raw bytes for invalid type
'
,
()
=>
{
...
@@ -57,12 +60,16 @@ describe('parseFoo', () => {
...
@@ -57,12 +60,16 @@ describe('parseFoo', () => {
const
str
=
'
Hello World
'
const
str
=
'
Hello World
'
const
bytes
=
BigNumber
.
from
(
toUtf8Bytes
(
str
)).
toHexString
()
as
WagmiBytes
const
bytes
=
BigNumber
.
from
(
toUtf8Bytes
(
str
)).
toHexString
()
as
WagmiBytes
expect
(
parseString
(
bytes
)).
toBe
(
str
)
expect
(
parseString
(
bytes
)).
toBe
(
str
)
expect
(
parseString
(
'
0x
'
)).
toMatchInlineSnapshot
(
'
""
'
)
expect
(
parseString
(
'
0x0
'
)).
toMatchInlineSnapshot
(
'
""
'
)
expect
(
parseString
(
'
0x0
'
)).
toMatchInlineSnapshot
(
'
""
'
)
})
})
it
(
'
works for numbers
'
,
()
=>
{
it
(
'
works for numbers
'
,
()
=>
{
const
num
=
123
const
num
=
123
const
bytes
=
BigNumber
.
from
(
num
).
toHexString
()
as
WagmiBytes
const
bytes
=
BigNumber
.
from
(
num
).
toHexString
()
as
WagmiBytes
expect
(
parseNumber
(
bytes
)).
toEqual
(
BigNumber
.
from
(
num
))
expect
(
parseNumber
(
bytes
)).
toEqual
(
BigNumber
.
from
(
num
))
expect
(
parseNumber
(
'
0x
'
)).
toEqual
(
BigNumber
.
from
(
0
))
})
})
it
(
'
works for addresses
'
,
()
=>
{
it
(
'
works for addresses
'
,
()
=>
{
...
@@ -74,5 +81,8 @@ describe('parseFoo', () => {
...
@@ -74,5 +81,8 @@ describe('parseFoo', () => {
it
(
'
works for booleans
'
,
()
=>
{
it
(
'
works for booleans
'
,
()
=>
{
const
bytes
=
BigNumber
.
from
(
1
).
toHexString
()
as
WagmiBytes
const
bytes
=
BigNumber
.
from
(
1
).
toHexString
()
as
WagmiBytes
expect
(
parseBool
(
bytes
)).
toBe
(
true
)
expect
(
parseBool
(
bytes
)).
toBe
(
true
)
expect
(
parseBool
(
'
0x
'
)).
toBe
(
false
)
expect
(
parseBool
(
'
0x0
'
)).
toBe
(
false
)
expect
(
parseBool
(
'
0x00000
'
)).
toBe
(
false
)
})
})
})
})
packages/atst/src/lib/parseAttestationBytes.ts
View file @
36da4222
...
@@ -10,7 +10,7 @@ import { ParseBytesReturn } from '../types/ParseBytesReturn'
...
@@ -10,7 +10,7 @@ import { ParseBytesReturn } from '../types/ParseBytesReturn'
* Parses a string attestion
* Parses a string attestion
*/
*/
export
const
parseString
=
(
rawAttestation
:
WagmiBytes
):
string
=>
{
export
const
parseString
=
(
rawAttestation
:
WagmiBytes
):
string
=>
{
rawAttestation
=
rawAttestation
===
'
0x
'
?
'
0x0
'
:
rawAttestation
rawAttestation
=
rawAttestation
===
'
0x
0
'
?
'
0x
'
:
rawAttestation
return
rawAttestation
?
toUtf8String
(
rawAttestation
)
:
''
return
rawAttestation
?
toUtf8String
(
rawAttestation
)
:
''
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment