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
922041eb
Unverified
Commit
922041eb
authored
Mar 08, 2023
by
mergify[bot]
Committed by
GitHub
Mar 08, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5072 from ethereum-optimism/willc/create-key
feat(atst): Use createKey internally in function
parents
bee42be3
b3a7009e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
37 deletions
+52
-37
flat-adults-hope.md
.changeset/flat-adults-hope.md
+5
-0
createValue.spec.ts
packages/atst/src/lib/createValue.spec.ts
+0
-0
getEvents.spec.ts
packages/atst/src/lib/getEvents.spec.ts
+29
-0
prepareWriteAttestation.spec.ts
packages/atst/src/lib/prepareWriteAttestation.spec.ts
+5
-7
prepareWriteAttestation.ts
packages/atst/src/lib/prepareWriteAttestation.ts
+2
-10
prepareWriteAttestations.spec.ts
packages/atst/src/lib/prepareWriteAttestations.spec.ts
+5
-7
readAttestation.spec.ts
packages/atst/src/lib/readAttestation.spec.ts
+4
-6
readAttestations.ts
packages/atst/src/lib/readAttestations.ts
+2
-7
No files found.
.changeset/flat-adults-hope.md
0 → 100644
View file @
922041eb
---
'
@eth-optimism/atst'
:
minor
---
Update readAttestations and prepareWriteAttestation to handle keys longer than 32 bytes
packages/atst/src/lib/createValue.spec.ts
deleted
100644 → 0
View file @
bee42be3
packages/atst/src/lib/getEvents.spec.ts
View file @
922041eb
...
@@ -76,6 +76,35 @@ describe(getEvents.name, () => {
...
@@ -76,6 +76,35 @@ describe(getEvents.name, () => {
"transactionHash": "0x61f59bd4dfe54272d9369effe3ae57a0ef2584161fcf2bbd55f5596002e759bd",
"transactionHash": "0x61f59bd4dfe54272d9369effe3ae57a0ef2584161fcf2bbd55f5596002e759bd",
"transactionIndex": 1,
"transactionIndex": 1,
},
},
{
"address": "0xEE36eaaD94d1Cc1d0eccaDb55C38bFfB6Be06C77",
"args": [
"0xBCf86Fd70a0183433763ab0c14E7a760194f3a9F",
"0x00000000000000000000000000000000000060A7",
"0x616e696d616c6661726d2e7363686f6f6c2e617474656e646564000000000000",
"0x01",
],
"blockHash": "0x4870baaac6d7195952dc25e5dc0109ea324f819f8152d2889c7b4ad64040a9bf",
"blockNumber": 6278428,
"data": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000",
"decode": [Function],
"event": "AttestationCreated",
"eventSignature": "AttestationCreated(address,address,bytes32,bytes)",
"getBlock": [Function],
"getTransaction": [Function],
"getTransactionReceipt": [Function],
"logIndex": 0,
"removeListener": [Function],
"removed": false,
"topics": [
"0x28710dfecab43d1e29e02aa56b2e1e610c0bae19135c9cf7a83a1adb6df96d85",
"0x000000000000000000000000bcf86fd70a0183433763ab0c14e7a760194f3a9f",
"0x00000000000000000000000000000000000000000000000000000000000060a7",
"0x616e696d616c6661726d2e7363686f6f6c2e617474656e646564000000000000",
],
"transactionHash": "0x4e836b74c51a370375efa374297524d9b0f6eacdd699c30556680ae7dc9a14ea",
"transactionIndex": 1,
},
]
]
`
)
`
)
})
})
...
...
packages/atst/src/lib/prepareWriteAttestation.spec.ts
View file @
922041eb
...
@@ -43,7 +43,7 @@ describe(prepareWriteAttestation.name, () => {
...
@@ -43,7 +43,7 @@ describe(prepareWriteAttestation.name, () => {
expect
(
result
.
address
).
toMatchInlineSnapshot
(
expect
(
result
.
address
).
toMatchInlineSnapshot
(
'
"0xEE36eaaD94d1Cc1d0eccaDb55C38bFfB6Be06C77"
'
'
"0xEE36eaaD94d1Cc1d0eccaDb55C38bFfB6Be06C77"
'
)
)
expect
(
result
.
chainId
).
toMatchInlineSnapshot
(
'
10
'
)
expect
(
result
.
chainId
).
toMatchInlineSnapshot
(
'
undefined
'
)
expect
(
result
.
functionName
).
toMatchInlineSnapshot
(
'
"attest"
'
)
expect
(
result
.
functionName
).
toMatchInlineSnapshot
(
'
"attest"
'
)
expect
(
result
.
mode
).
toMatchInlineSnapshot
(
'
"prepared"
'
)
expect
(
result
.
mode
).
toMatchInlineSnapshot
(
'
"prepared"
'
)
expect
(
result
.
request
.
gasLimit
).
toMatchInlineSnapshot
(
`
expect
(
result
.
request
.
gasLimit
).
toMatchInlineSnapshot
(
`
...
@@ -54,18 +54,16 @@ describe(prepareWriteAttestation.name, () => {
...
@@ -54,18 +54,16 @@ describe(prepareWriteAttestation.name, () => {
`
)
`
)
})
})
it
(
'
should
throw an error if key is
longer than 32 bytes
'
,
async
()
=>
{
it
(
'
should
work for key
longer than 32 bytes
'
,
async
()
=>
{
const
dataType
=
'
string
'
const
dataType
=
'
string
'
await
expect
(
expect
(
readAttestation
(
await
readAttestation
(
creator
,
creator
,
about
,
about
,
'
this is a key that is way longer than 32 bytes so this key should throw an error matching the inline snapshot
'
,
'
this is a key that is way longer than 32 bytes so this key should throw an error matching the inline snapshot
'
,
dataType
dataType
)
)
).
rejects
.
toThrowErrorMatchingInlineSnapshot
(
).
toMatchInlineSnapshot
(
'
""
'
)
'
"Key is longer than the max length of 32 for attestation keys"
'
)
})
})
})
})
packages/atst/src/lib/prepareWriteAttestation.ts
View file @
922041eb
import
{
Address
,
prepareWriteContract
}
from
'
@wagmi/core
'
import
{
Address
,
prepareWriteContract
}
from
'
@wagmi/core
'
import
{
formatBytes32String
}
from
'
ethers/lib/utils.js
'
import
{
ATTESTATION_STATION_ADDRESS
}
from
'
../constants/attestationStationAddress
'
import
{
ATTESTATION_STATION_ADDRESS
}
from
'
../constants/attestationStationAddress
'
import
{
WagmiBytes
}
from
'
../types/WagmiBytes
'
import
{
WagmiBytes
}
from
'
../types/WagmiBytes
'
import
{
abi
}
from
'
./abi
'
import
{
abi
}
from
'
./abi
'
import
{
createKey
}
from
'
./createKey
'
import
{
createValue
}
from
'
./createValue
'
import
{
createValue
}
from
'
./createValue
'
export
const
prepareWriteAttestation
=
async
(
export
const
prepareWriteAttestation
=
async
(
...
@@ -13,15 +13,7 @@ export const prepareWriteAttestation = async (
...
@@ -13,15 +13,7 @@ export const prepareWriteAttestation = async (
chainId
:
number
|
undefined
=
undefined
,
chainId
:
number
|
undefined
=
undefined
,
contractAddress
:
Address
=
ATTESTATION_STATION_ADDRESS
contractAddress
:
Address
=
ATTESTATION_STATION_ADDRESS
)
=>
{
)
=>
{
let
formattedKey
:
WagmiBytes
const
formattedKey
=
createKey
(
key
)
as
WagmiBytes
try
{
formattedKey
=
formatBytes32String
(
key
)
as
WagmiBytes
}
catch
(
e
)
{
console
.
error
(
e
)
throw
new
Error
(
`key is longer than 32 bytes:
${
key
}
. Try using a shorter key or using 'encodeRawKey' to encode the key into 32 bytes first`
)
}
return
prepareWriteContract
({
return
prepareWriteContract
({
address
:
contractAddress
,
address
:
contractAddress
,
abi
,
abi
,
...
...
packages/atst/src/lib/prepareWriteAttestations.spec.ts
View file @
922041eb
...
@@ -49,7 +49,7 @@ describe(prepareWriteAttestations.name, () => {
...
@@ -49,7 +49,7 @@ describe(prepareWriteAttestations.name, () => {
expect
(
result
.
address
).
toMatchInlineSnapshot
(
expect
(
result
.
address
).
toMatchInlineSnapshot
(
'
"0xEE36eaaD94d1Cc1d0eccaDb55C38bFfB6Be06C77"
'
'
"0xEE36eaaD94d1Cc1d0eccaDb55C38bFfB6Be06C77"
'
)
)
expect
(
result
.
chainId
).
toMatchInlineSnapshot
(
'
10
'
)
expect
(
result
.
chainId
).
toMatchInlineSnapshot
(
'
undefined
'
)
expect
(
result
.
functionName
).
toMatchInlineSnapshot
(
'
"attest"
'
)
expect
(
result
.
functionName
).
toMatchInlineSnapshot
(
'
"attest"
'
)
expect
(
result
.
mode
).
toMatchInlineSnapshot
(
'
"prepared"
'
)
expect
(
result
.
mode
).
toMatchInlineSnapshot
(
'
"prepared"
'
)
expect
(
result
.
request
.
gasLimit
).
toMatchInlineSnapshot
(
`
expect
(
result
.
request
.
gasLimit
).
toMatchInlineSnapshot
(
`
...
@@ -60,18 +60,16 @@ describe(prepareWriteAttestations.name, () => {
...
@@ -60,18 +60,16 @@ describe(prepareWriteAttestations.name, () => {
`
)
`
)
})
})
it
(
'
should
throw an error
if key is longer than 32 bytes
'
,
async
()
=>
{
it
(
'
should
work
if key is longer than 32 bytes
'
,
async
()
=>
{
const
dataType
=
'
string
'
const
dataType
=
'
string
'
await
expect
(
expect
(
readAttestation
(
await
readAttestation
(
creator
,
creator
,
about
,
about
,
'
this is a key that is way longer than 32 bytes so this key should throw an error matching the inline snapshot
'
,
'
this is a key that is way longer than 32 bytes so this key should throw an error matching the inline snapshot
'
,
dataType
dataType
)
)
).
rejects
.
toThrowErrorMatchingInlineSnapshot
(
).
toMatchInlineSnapshot
(
'
""
'
)
'
"Key is longer than the max length of 32 for attestation keys"
'
)
})
})
})
})
packages/atst/src/lib/readAttestation.spec.ts
View file @
922041eb
...
@@ -26,16 +26,14 @@ describe(readAttestation.name, () => {
...
@@ -26,16 +26,14 @@ describe(readAttestation.name, () => {
)
)
})
})
it
(
'
should
throw an error
if key is longer than 32 bytes
'
,
async
()
=>
{
it
(
'
should
work
if key is longer than 32 bytes
'
,
async
()
=>
{
await
expect
(
expect
(
readAttestation
(
await
readAttestation
(
creator
,
creator
,
about
,
about
,
'
this is a key that is way longer than 32 bytes so this key should throw an error matching the inline snapshot
'
,
'
this is a key that is way longer than 32 bytes so this key should throw an error matching the inline snapshot
'
,
dataType
dataType
)
)
).
rejects
.
toThrowErrorMatchingInlineSnapshot
(
).
toMatchInlineSnapshot
(
'
""
'
)
'
"Key is longer than the max length of 32 for attestation keys"
'
)
})
})
})
})
packages/atst/src/lib/readAttestations.ts
View file @
922041eb
import
{
readContracts
}
from
'
@wagmi/core
'
import
{
readContracts
}
from
'
@wagmi/core
'
import
{
formatBytes32String
}
from
'
ethers/lib/utils.js
'
import
{
ATTESTATION_STATION_ADDRESS
}
from
'
../constants/attestationStationAddress
'
import
{
ATTESTATION_STATION_ADDRESS
}
from
'
../constants/attestationStationAddress
'
import
type
{
AttestationReadParams
}
from
'
../types/AttestationReadParams
'
import
type
{
AttestationReadParams
}
from
'
../types/AttestationReadParams
'
import
{
DEFAULT_DATA_TYPE
}
from
'
../types/DataTypeOption
'
import
{
DEFAULT_DATA_TYPE
}
from
'
../types/DataTypeOption
'
import
type
{
WagmiBytes
}
from
'
../types/WagmiBytes
'
import
type
{
WagmiBytes
}
from
'
../types/WagmiBytes
'
import
{
abi
}
from
'
./abi
'
import
{
abi
}
from
'
./abi
'
import
{
createKey
}
from
'
./createKey
'
import
{
parseAttestationBytes
}
from
'
./parseAttestationBytes
'
import
{
parseAttestationBytes
}
from
'
./parseAttestationBytes
'
/**
/**
...
@@ -39,16 +39,11 @@ export const readAttestations = async (
...
@@ -39,16 +39,11 @@ export const readAttestations = async (
key
,
key
,
contractAddress
=
ATTESTATION_STATION_ADDRESS
,
contractAddress
=
ATTESTATION_STATION_ADDRESS
,
}
=
attestation
}
=
attestation
if
(
key
.
length
>
32
)
{
throw
new
Error
(
'
Key is longer than the max length of 32 for attestation keys
'
)
}
return
{
return
{
address
:
contractAddress
,
address
:
contractAddress
,
abi
,
abi
,
functionName
:
'
attestations
'
,
functionName
:
'
attestations
'
,
args
:
[
creator
,
about
,
formatBytes32String
(
key
)
as
WagmiBytes
],
args
:
[
creator
,
about
,
createKey
(
key
)
as
WagmiBytes
],
}
as
const
}
as
const
})
})
...
...
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