Skip to content

Commit

Permalink
Add stealth client actions content (#9)
Browse files Browse the repository at this point in the history
* feat: generateStealthAddress

feat: more context on ephemeral priv key

feat: show res vars

feat: computeStealthKey

feat: return values

feat: use tabs

chore: format

fix: tabs

fix: format

chore: format

feat: checkStealthAddress

fix: solidity event def

chore: format

feat: stealth client

feat: getAnnouncements doc page

feat: getAnnouncementsForUser

feat: getStealthMetaAddress

fix: stealthClient ref

feat: prepareAnnounce

feat: prepareRegisterKeys

feat: prepareRegisterKeysOnBehalf

feat: watchAnnouncementsForUser

feat: alphabetize types in glossary

chore: format

Correct highlighted lines

feat: glossary terms (#6)

* feat: terms

* chore: format

* Fix nits

---------

Co-authored-by: garyghayrat <[email protected]>

* Remove repeated types

---------

Co-authored-by: marcomariscal <[email protected]>
  • Loading branch information
garyghayrat and marcomariscal committed May 7, 2024
1 parent 1a779f7 commit 54a0f76
Show file tree
Hide file tree
Showing 15 changed files with 1,106 additions and 12 deletions.
2 changes: 2 additions & 0 deletions pages/SDK/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"overview": "Overview",
"getting-started": "Getting Started",
"guides": "Guides",
"stealth-client": "Stealth Client",
"actions": "Actions",
"utilities": "Utilities",
"glossary": "Glossary"
}
10 changes: 10 additions & 0 deletions pages/SDK/actions/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"index": "Overview",
"getAnnouncements": "getAnnouncements",
"getAnnouncementsForUser": "getAnnouncementsForUser",
"getStealthMetaAddress": "getStealthMetaAddress",
"prepareAnnounce": "prepareAnnounce",
"prepareRegisterKeys": "prepareRegisterKeys",
"prepareRegisterKeysOnBehalf": "prepareRegisterKeysOnBehalf",
"watchAnnouncementsForUser": "watchAnnouncementsForUser"
}
115 changes: 115 additions & 0 deletions pages/SDK/actions/getAnnouncements.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import { Tabs } from "nextra/components";

# getAnnouncements

Get announcement event logs from the `ERC5564Announcer` contract.

## Usage

<Tabs items={['example.ts', 'client.ts']} selectedIndex={0}>
<Tabs.Tab>
```ts {11-20}
import { stealthClient } from './client';

const announcements = await stealthClient.getAnnouncements({
ERC5564Address,
args,
fromBlock,
toBlock
});

/*
[
{
caller: "0x...",
ephemeralPubKey: "0x...",
metadata: "0x...",
schemeId: 1n,
stealthAddress: "0x...",
more log data...
}
]
*/
```

</Tabs.Tab>
<Tabs.Tab>
```ts
import { createStealthClient } from "@scopelift/stealth-address-sdk";
export const stealthClient = createStealthClient({
chainId,
rpcUrl,
});
```

</Tabs.Tab>
</Tabs>

## Return Value

- **Type:** [`GetAnnouncementsReturnType`](../glossary/types.md#getannouncementsreturntype)

An array of `Announce` event log data emitted from the `ERC5564Announcer` contract.

## Parameters

### ERC5564Address

- **Type:** [`HexString`](../glossary/types.md#hexstring)

The address of the `ERC5564Announcer` contract.

```ts {2}
const announcements = await stealthClient.getAnnouncements({
ERC5564Address,
args,
fromBlock,
toBlock,
});
```

### args

- **Type:** [`AnnouncementArgs`](../glossary/types.md#announcementargs)

The arguments to filter the `Announce` event logs.

```ts {3}
const announcements = await stealthClient.getAnnouncements({
ERC5564Address,
args,
fromBlock,
toBlock,
});
```

### fromBlock

- **Type:** [`BlockType`](../glossary/types.md#blocktype)

The block number to start fetching logs from.

```ts {4}
const announcements = await stealthClient.getAnnouncements({
ERC5564Address,
args,
fromBlock,
toBlock,
});
```

### toBlock

- **Type:** [`BlockType`](../glossary/types.md#blocktype)

The block number to stop fetching logs at.

```ts {5}
const announcements = await stealthClient.getAnnouncements({
ERC5564Address,
args,
fromBlock,
toBlock,
});
```
138 changes: 138 additions & 0 deletions pages/SDK/actions/getAnnouncementsForUser.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import { Tabs } from "nextra/components";

# getAnnouncementsForUser

Filters a list of given announcements based on if they are relevant for the user.

## Usage

<Tabs items={['example.ts', 'client.ts']} selectedIndex={0}>
<Tabs.Tab>
```ts
import { stealthClient } from "./client";

const userAnnouncements = await stealthClient.getAnnouncementsForUser({
announcements,
spendingPublicKey,
viewingPrivateKey,
excludeList,
includeList
});

/*
Array of announcements relevant to the user.
[
{
caller: "0x...",
ephemeralPubKey: "0x...",
metadata: "0x...",
schemeId: 1n,
stealthAddress: "0x...",
more log data...
}
]
*/
```

</Tabs.Tab>
<Tabs.Tab>
```ts
import { createStealthClient } from "@scopelift/stealth-address-sdk";
export const stealthClient = createStealthClient({
chainId,
rpcUrl,
});
```

</Tabs.Tab>
</Tabs>

## Return Value

- **Type:** [`GetAnnouncementsForUserReturnType`](../glossary/types.md#getannouncementsforuserreturntype)

An array of announcements relevant to the user, filtered by the provided criteria.

## Parameters

### announcements

- **Type:** [`AnnouncementLog[]`](../glossary/types.md#announcementlog)

An array of announcement logs to be processed and filtered.

```ts {2}
const userAnnouncements = await stealthClient.getAnnouncementsFroUser({
announcements,
spendingPublicKey,
viewingPrivateKey,
excludeList,
includeList,
});
```

### spendingPublicKey

- **Type:** [`HexString`](../glossary/types.md#hexstring)

The user's spending public key.

```ts {3}
const userAnnouncements = await stealthClient.getAnnouncementsFroUser({
announcements,
spendingPublicKey,
viewingPrivateKey,
excludeList,
includeList,
});
```

### viewingPrivateKey

- **Type:** [`HexString`](../glossary/types.md#hexstring)

The user's viewing private key.

```ts {4}
const userAnnouncements = await stealthClient.getAnnouncementsFroUser({
announcements,
spendingPublicKey,
viewingPrivateKey,
excludeList,
includeList,
});
```

### excludeList (optional)

- **Type:** [`EthAddress[]`](../glossary/types.md#ethaddress)

Addresses to exclude from the results.

```ts {5}
const userAnnouncements = await stealthClient.getAnnouncementsFroUser({
announcements,
spendingPublicKey,
viewingPrivateKey,
excludeList,
includeList,
});
```

### includeList (optional)

- **Type:** [`EthAddress[]`](../glossary/types.md#ethaddress)

Addresses to specifically include in the results.

```ts {6}
const userAnnouncements = await stealthClient.getAnnouncementsFroUser({
announcements,
spendingPublicKey,
viewingPrivateKey,
excludeList,
includeList,
});
```
85 changes: 85 additions & 0 deletions pages/SDK/actions/getStealthMetaAddress.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { Tabs } from "nextra/components";

# getStealthMetaAddress

Retrieves a stealth meta-address from the ERC-6538 Registry contract.

## Usage

<Tabs items={['example.ts', 'client.ts']} selectedIndex={0}>
<Tabs.Tab>
```ts
import { stealthClient } from "./client";

const stealthMetaAddress = await stealthClient.getStealthMetaAddress({
ERC6538Address,
registrant,
schemeId
});

// '0x...'
```

</Tabs.Tab>
<Tabs.Tab>
```ts
import { createStealthClient } from "@scopelift/stealth-address-sdk";
export const stealthClient = createStealthClient({
chainId,
rpcUrl,
});
```

</Tabs.Tab>
</Tabs>

## Return Value

- **Type:** [`HexString`](../glossary/types.md#hexstring)

The stealth meta address of the registrant.

## Parameters

### ERC6538Address

- **Type:** [`HexString`](../glossary/types.md#hexstring)

The address of the ERC-6538 Registry contract.

```ts {2}
const stealthMetaAddress = await stealthClient.getStealthMetaAddress({
ERC6538Address,
registrant,
schemeId,
});
```

### registrant

- **Type:** [`EthAddress`](../glossary/types.md#ethaddress)

The identifier of the registrant, which could be an Ethereum address or an ENS name.

```ts {3}
const stealthMetaAddress = await stealthClient.getStealthMetaAddress({
ERC6538Address,
registrant,
schemeId,
});
```

### schemeId

- **Type:** [`VALID_SCHEME_ID`](../glossary/types.md#valid_scheme_id)

The ID of the stealth address scheme.

```ts {4}
const stealthMetaAddress = await stealthClient.getStealthMetaAddress({
ERC6538Address,
registrant,
schemeId,
});
```
27 changes: 27 additions & 0 deletions pages/SDK/actions/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Overview

The SDK provides a suite of actions that enable developers to handle various stealth address-related functionalities seamlessly.

These actions can be consumed from an initialized `stealthClient` instance:

```ts
import { createStealthClient } from "@scopelift/stealth-address-sdk";

const stealthClient = createStealthClient({
chainId,
rpcUrl,
});

const announcements = await stealthClient.getAnnouncements(...args);
```

Or alternatively, you can call the action directly by passing the [`clientParams`](../glossary/types.md#clientparams) object with `chainId` and `rpcUrl`:

```ts
import { getAnnouncements } from "@scopelift/stealth-address-sdk";

const announcements = await getAnnouncements({
clientParams: { chainId, rpcUrl },
...args,
});
```
Loading

0 comments on commit 54a0f76

Please sign in to comment.