Skip to content

Commit

Permalink
docs: Add chain id parameter to config creation (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc authored Jan 31, 2025
1 parent 35876ea commit 25b9a40
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions docs.renegade.fi/docs/technical-reference/typescript-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const viemClient = createPublicClient({
})

export const config = createConfig({
chainId: arbitrum.id,
darkPoolAddress: "0x30bd8eab29181f790d7e495786d4b96d7afdc518",
priceReporterUrl: "mainnet.price-reporter.renegade.fi",
relayerUrl: "mainnet.cluster0.renegade.fi",
Expand All @@ -39,6 +40,27 @@ export const config = createConfig({

:::tip

If you have your chain ID configured in your `.env` file, you can use the `isSupportedChainId` function to check if a chain is supported. This function also acts as a type guard, narrowing the type to `SupportedChainId` when it returns `true`.

```jsx
import { isSupportedChainId } from "@renegade-fi/node"

// Get chain ID from environment variables and convert to number
const chainId = Number(process.env.CHAIN_ID)
const isSupported = isSupportedChainId(chainId)

if (isSupported) {
// chainId is now narrowed to SupportedChainId type
console.log("Chain is supported: ", chainId)
} else {
console.log("Chain is not supported")
}
```

:::

:::tip

Follow the instructions [here](https://viem.sh/docs/clients/public) to properly configure `viemClient` for either the Arbitrum One chain or the Arbitrum Sepolia chain, depending on which environment you want to use.

:::
Expand Down Expand Up @@ -78,7 +100,7 @@ For Typescript configuration, check out this [example repo](https://stackblitz.c
## Protocol Core Concepts

### Relayer
A relayer node is resposible for the matching and settlement of orders. Each individual relayer manages one or more wallets, meaning they are able to view the plaintext wallet but are unable to modify a wallet. In order to modify a wallet (placing orders, depositing assets, etc.), users sign updates to their wallet state and queue asynchronous tasks in the relayer.
A relayer node is resposible for the matching and settlement of orders. Each individual relayer manages one or more wallets, meaning they are able to view the plaintext wallet but are unable to modify a wallet. In order to modify a wallet (placing orders, depositing assets, etc.), users sign updates to their wallet state and queue asynchronous "tasks" in the relayer.

:::note
Relayers manage task queues for each wallet, which means you do not necessarily need to wait for a task to complete before creating a new task. This is why two functions exist for fetching a wallet's state: [`getWalletFromRelayer`](#getwalletfromrelayer) (current wallet state) and [`getBackOfQueueWallet`](#getbackofqueuewallet) (wallet state after current task queue is cleared).
Expand Down Expand Up @@ -185,6 +207,7 @@ const publicClient = createPublicClient({
})

export const config = createConfig({
chainId: arbitrum.id,
darkPoolAddress: "0x30bd8eab29181f790d7e495786d4b96d7afdc518",
priceReporterUrl: "mainnet.price-reporter.renegade.fi",
relayerUrl: "mainnet.cluster0.renegade.fi",
Expand All @@ -196,13 +219,13 @@ export const config = createConfig({

- darkPoolAddress
- `0x${string}`
- The darkpool contracts address.
- The darkpool contract's address.
- priceReporterUrl
- `string`
- The price reporters URL.
- The price reporter's URL.
- relayerUrl
- `string`
- The relayers URL.
- The relayer's URL.
- viemClient
- [`PublicClient`](https://viem.sh/docs/clients/public)
- Viem client used for wallet specific tasks e.g. signing a message.
Expand Down Expand Up @@ -237,7 +260,7 @@ export const config = createAuthConfig({

- authServerUrl
- `string`
- The auth servers URL.
- The auth server's URL.
- apiKey
- `string`
- The API key. Used to authorize requests to the server.
Expand Down Expand Up @@ -280,7 +303,7 @@ import { createExternalKeyConfig } from "@renegade-fi/node"
- WebSocket URL of the relayer
- `darkPoolAddress`
- `0x${string}`
- The darkpool contracts address.
- The darkpool contract's address.
- `viemClient`
- [`PublicClient`](https://viem.sh/docs/clients/public)
- Viem client used for wallet specific tasks e.g. signing a message.
Expand All @@ -296,6 +319,7 @@ const publicClient = createPublicClient({
transport: http()
})
const config = createExternalKeyConfig({
chainId: arbitrumSepolia.id,
signMessage,
publicKey: "0x04800db50009a01fab58a239f204ca14e85682ca0991cb6914f34c4fbd0131eedb54d0ccbe392922e57486b031779bf8b6feab57971c2c406df291c0ab9c529a3d",
symmetricKey: walletSecrets.symmetric_key,
Expand Down Expand Up @@ -428,7 +452,7 @@ An error may be thrown if:

### getWalletFromRelayer

Action for fetching a wallets state from your connected relayer.
Action for fetching a wallet's state from your connected relayer.

**Import**

Expand Down Expand Up @@ -538,7 +562,7 @@ const { taskId } = await deposit(config, {
- The latest possible block timestamp for when this permit is valid.
- permit
- `0x${string}`
- The corresponding EIP-712 signature for the permit2 message, signed by `owner`. If the recovered address from signature verification does not match `owner`, the call will fail.
- The corresponding EIP-712 signature for the permit2 message, signed by `owner`. If the recovered address from signature verification does not match `owner`, the call will fail.

**Return Type**

Expand Down

0 comments on commit 25b9a40

Please sign in to comment.