Commit 3bdec7c3 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into willc/eventfilters

parents 0d37cf14 45c15633
...@@ -32,7 +32,7 @@ npm install @eth-optimism/atst wagmi @wagmi/core ethers@5.7.0 ...@@ -32,7 +32,7 @@ npm install @eth-optimism/atst wagmi @wagmi/core ethers@5.7.0
The typescript sdk provides a clean [wagmi](https://wagmi.sh/) based interface for reading and writing to the attestation station The typescript sdk provides a clean [wagmi](https://wagmi.sh/) based interface for reading and writing to the attestation station
### See [sdk docs]() for usage instructions ### See [sdk docs](https://github.com/ethereum-optimism/optimism/blob/develop/packages/atst/docs/sdk.md) for usage instructions
## atst cli ## atst cli
...@@ -40,16 +40,28 @@ The cli provides a convenient cli for interacting with the attestation station c ...@@ -40,16 +40,28 @@ The cli provides a convenient cli for interacting with the attestation station c
TODO put a gif here of using it TODO put a gif here of using it
## React instructions ## React API
For react hooks we recomend using the [wagmi cli](https://wagmi.sh/cli/getting-started) with the [etherscan plugin](https://wagmi.sh/cli/plugins/etherscan) and [react plugin](https://wagmi.sh/cli/plugins/react) to automatically generate react hooks around the attestation station. See [example/react](http://todo.todo.todo) for an example. For react hooks we recomend using the [wagmi cli](https://wagmi.sh/cli/getting-started) with the [etherscan plugin](https://wagmi.sh/cli/plugins/etherscan) and [react plugin](https://wagmi.sh/cli/plugins/react) to automatically generate react hooks around the attestation station.
Use `parseAttestationBytes` and `stringifyAttestationBytes` to parse and stringify attestations before passing them into wagmi hooks. Use `parseAttestationBytes` and `stringifyAttestationBytes` to parse and stringify attestations before passing them into wagmi hooks.
For convenience we also export the hooks here.
`useAttestationStationAttestation` - Reads attestations with useContractRead
`useAttestationStationVersion` - Reads attestation version
`useAttestationStationAttest` - Wraps useContractWrite with attestation station abi calling attest
`usePrepareAttestationStationAttest` - Wraps usePrepare with attestation station abi calling attest
`useAttestationStationAttestationCreatedEvent` - Wraps useContractEvents for Created events
Also some more hooks exported by the cli but these are likely the only ones you need.
## Contributing ## Contributing
Please see our [contributing.md](/docs/contributing.md). No contribution is too small. Please see our [contributing.md](docs/contributing.md). No contribution is too small.
Having your contribution denied feels bad. Please consider opening an issue before adding any new features or apis Having your contribution denied feels bad. Please consider opening an issue before adding any new features or apis
## Check [Awesome ATST](https://todo.todo.todo) for awesome tools and examples around the attestation station
...@@ -54,21 +54,26 @@ createClient({ ...@@ -54,21 +54,26 @@ createClient({
### Reading an attestation ### Reading an attestation
To read an attestation use `readString`, `readAddress`, `readNumber`, `readBool`
Use `readAttestationString` with `bytes` passed in for the types parameter to read raw bytes
Here is an example of reading an attestation used by the optimist nft Here is an example of reading an attestation used by the optimist nft
```typescript ```typescript
import { readAttestation } from '@eth-optimism/atst' import { readAttestationString } from '@eth-optimism/atst'
const creator = '0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3' const creator = '0x60c5C9c98bcBd0b0F2fD89B24c16e533BaA8CdA3'
const about = '0x2335022c740d17c2837f9C884Bfe4fFdbf0A95D5' const about = '0x2335022c740d17c2837f9C884Bfe4fFdbf0A95D5'
const key = 'optimist.base-uri' const key = 'optimist.base-uri'
const dataType = 'string' // note string is default
const attestation = await readAttestation(creator, about, key, dataType) const str = await readAttestationString(creator, about, key)
console.log(attestation) // https://assets.optimism.io/4a609661-6774-441f-9fdb-453fdbb89931-bucket/optimist-nft/attributes console.log(attestation) // https://assets.optimism.io/4a609661-6774-441f-9fdb-453fdbb89931-bucket/optimist-nft/attributes
``` ```
### Reading multiple Attestations
If reading more than one attestation you can use readAttestations to read them with multicall If reading more than one attestation you can use readAttestations to read them with multicall
### Writing an attestation ### Writing an attestation
...@@ -174,11 +179,16 @@ const attestation = await readAttestations({ ...@@ -174,11 +179,16 @@ const attestation = await readAttestations({
}) })
``` ```
### parseAttestationBytes ### Parsing bytes
These utilities for parsing bytes are provided:
Parses raw bytes from the attestation station based on the type. `parseAddress`
`parseNumber`
`parseBool`
`parseString`
Note: `readAttestation` and `readAttestations` already parse the bytes so this is only necessary if reading attestations directly from chain instead of through this sdkA Note: `readAttestation` and `readAttestations` already parse the bytes so this is only necessary if reading attestations directly from chain instead of through this utility
```typescript ```typescript
const attestation = parseAttestationBytes( const attestation = parseAttestationBytes(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment